[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?
2 Answers

(Hussein Abuthuraya(MSFT))

7/12/2002 1:32:00 AM

0

Hi Wil,

If you know the DataTypes of the columns in a DataRow of a DataReader then you have to be explicit when using the Getxxxxx functions because it expects to find the correct
datatype in the column. There is no implicit castings with the Get methods of all DataReaders (Odbc, OleDb and SQlClient).

If you don't know the columns datatype before hand, then don't use the Get methods. Just access the Column value directly like dr("MyFiledName"). Ofcourse this has it's
own Penalty as far as performance because it has to do some implicit datatype conversion.

So you choose the convenient way to access the values based on the availability of the data type to your application in advance.


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.co....


(Wil)

7/12/2002 8:03:00 PM

0

Nevermind, the provider depends on the ODBC driver to do the conversion.