Datareader and Getint32 does not work

  • Thread starter Peter Stojkovic
  • 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
 
W

William Ryan

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

MyInt32 = cmd.ExecuteScalar?
 
M

Miha Markic

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.
 
P

Peter Stojkovic

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top