[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

OdbcDataReader Getters Bug or limitation?

(Wil)

7/11/2002 11:02:00 PM

I have an integer datatype defined in my odbc datasource, when I
attempt to do a GetString() from the OdbcDataReader, it throws an
InvalidCastException, why can't the .NET ODBC data provider convert it
to a string for me? Is this a limitation or is it a "strong type"
feature?

Wil
1 Answer

Chirag Gupta

9/5/2002 3:52:00 AM

0

This is not the right way to use GetString(). GetString()
we use only when datatype is varchar. Otherwise for type
casting we use ToString function. Syntax would be
something like this:-

myReader.GetValue(0).ToString()

If you know the data type you can replace GetValue() with
GetInt32, GetString etc....

I hope this helps.


>-----Original Message-----
>I have an integer datatype defined in my odbc datasource,
when I
>attempt to do a GetString() from the OdbcDataReader, it
throws an
>InvalidCastException, why can't the .NET ODBC data
provider convert it
>to a string for me? Is this a limitation or is it
a "strong type"
>feature?
>
>Wil
>.
>