This is a discussion on Displaying a CHAR FOR BIT DATA in C# within the DB2 forums, part of the Database Server Software category; --> ///C# Code OdbcConnection con = new OdbcConnection(connection string); con.Open(); OdbcCommand cmd = new OdbcCommand("select nsilunique_id from nstbale",con); OdbcDataReader dr ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| ///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. |
| |||
| jburkle19@gmail.com wrote: > ///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. > 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 -- Serge Rielau DB2 Solutions Development DB2 UDB for Linux, Unix, Windows IBM Toronto Lab |
| ||||
| jburkle19@gmail.com wrote: > ///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' 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. -- Knut Stolze DB2 Information Integration Development IBM Germany |