Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / January 2006

Tip: Looking for answers? Try searching our database.

Displaying a CHAR FOR BIT DATA in C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jburkle19@gmail.com - 06 Jan 2006 14:59 GMT
///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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.