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


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Re: Datareader and Getint32 does not work by William

William
Thu Dec 04 09:19:44 CST 2003

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

MyInt32 = cmd.ExecuteScalar?
"Peter Stojkovic" <peter.stojkovic@sms-eumuco.de> wrote in message
news:uqkFJinuDHA.3536@tk2msftngp13.phx.gbl...
> 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
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Re: Datareader and Getint32 does not work by Miha

Miha
Thu Dec 04 09:24:02 CST 2003

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.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"Peter Stojkovic" <peter.stojkovic@sms-eumuco.de> wrote in message
news:uqkFJinuDHA.3536@tk2msftngp13.phx.gbl...
> 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
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Re: Datareader and Getint32 does not work by Peter

Peter
Tue Dec 09 00:03:00 CST 2003

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


"Miha Markic" <miha at rthand com> wrote in message
news:%23yhJSsnuDHA.3496@TK2MSFTNGP11.phx.gbl...
> 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.
>
> --
> Miha Markic - RightHand .NET consulting & software development
> miha at rthand com
>
> "Peter Stojkovic" <peter.stojkovic@sms-eumuco.de> wrote in message
> news:uqkFJinuDHA.3536@tk2msftngp13.phx.gbl...
> > 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
> >
> >
> > *** Sent via Developersdex http://www.developersdex.com ***
> > Don't just participate in USENET...get rewarded for it!
>
>



Re: Datareader and Getint32 does not work by Miha

Miha
Tue Dec 09 01:24:12 CST 2003

Hi Peter,

Just out of curiosity, what database are you using.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Peter Stojkovic" <Peter.Stojkovic@gmx.net> wrote in message
news:uUtXdohvDHA.2304@TK2MSFTNGP12.phx.gbl...
> 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
>
>
> "Miha Markic" <miha at rthand com> wrote in message
> news:%23yhJSsnuDHA.3496@TK2MSFTNGP11.phx.gbl...
> > 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.
> >
> > --
> > Miha Markic - RightHand .NET consulting & software development
> > miha at rthand com
> >
> > "Peter Stojkovic" <peter.stojkovic@sms-eumuco.de> wrote in message
> > news:uqkFJinuDHA.3536@tk2msftngp13.phx.gbl...
> > > 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
> > >
> > >
> > > *** Sent via Developersdex http://www.developersdex.com ***
> > > Don't just participate in USENET...get rewarded for it!
> >
> >
>
>