///C# Code
OdbcConnection con = new OdbcConnection(connection string);
con.Open();
OdbcCommand cmd = new OdbcCommand("select nsilunique_id from
nstbale",con);
OdbcDataReader dr = cmd.ExecuteReader();
this.dgOrders.DataSource = dr;
this.dgOrders.DataBind();
When I bind that data to a column it displays:
System.Byte[] instead of the value in the coulmn which looks like
'200511120000002020000'
I tried casting it to a varchar in the SQL call, and storing it as a
string in the C# and either way it doesn't display in value.
I want it to return the '200511120000002020000' as somekind of string
so i can break it apart and create a date out of the first 8 digits of
it.
Any suggestions? I scoured the internet and couldn't find a solution.
Serge Rielau - 08 Jan 2006 00:08 GMT
> ///C# Code
>
[quoted text clipped - 19 lines]
>
> Any suggestions? I scoured the internet and couldn't find a solution.
Well, if you now C# all you need to no is to decode the BCD packed.
Anyway. Assuming the column is timestamp (by the looks of it) try this:
select rtrim(char(integer(date(nsilunique_id)))) from nstbale
date() will truncate the time
integer() will turn the date into an integer of the form 2005112
char() will turn teh inteer into '20051112 '
RTRIM() will trim the trailing spaces.
Cheers
Serge

Signature
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Knut Stolze - 09 Jan 2006 07:12 GMT
> ///C# Code
>
[quoted text clipped - 10 lines]
> System.Byte[] instead of the value in the coulmn which looks like
> '200511120000002020000'
CHAR FOR BIT DATA is binary data. So I'd say that the data type is exactly
what it ought to be. IF you want to convert the binary data to the
hex-representation, you have to resort to whatever facilities C# provides
for that.

Signature
Knut Stolze
DB2 Information Integration Development
IBM Germany