Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Type of sqldatareader column

Status
Not open for further replies.

NevG

Programmer
Oct 10, 2000
162
GB
Hi Gang

Can someone tell me the easiest way to determine and access a sqldatareader column. I am returning an unknown set of data and so I cannot specifically use GetInt32 or GetString etc... so Whats the easiest way for me to determine the data type of the column and then use it.

I would like to keep coding to amininum if possible.

Thanks

Nev G
 
Use the GetFieldType method.

Code:
if ( reader.GetFieldType( 0 ) == Type.GetType( "System.Int32" ) )
{
  // do something here
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top