Datareader and Getint32 does not work

  • Thread starter Thread starter Peter Stojkovic
  • Start date Start date
P

Peter Stojkovic

Using VS.2003 and ODBC

I make a SELECT count(*) from table1.
with ExecuteSQLSelect

This must return always !!! a number-value .

But if I try to read from the datareader with GetInt32 a get always a
inValid cast operation exception .
Only Getstring(0) works fine.

Is there any solution for this behavior ???


Thanks for any help

Peter
 
IF you are just looking for one value, why not use execute scalar?

MyInt32 = cmd.ExecuteScalar?
 
Hi Peter,

If ODBC is returning a string then there is no other solution than performin
a conversion (Convert.ToInt32).
You might check the returing type by assigning the value to an object and
see what type it is.
 
I know it is for example a double.
But it will be interpreted by whom ever as a string.
So only getstring works !! What a confusion !!
Peter
 
Back
Top