datareader - oracle reader returning System.Data.OracleClient.OracleCommand as value -


i'm stumped thing.

i'm using simple following code:

con.connectionstring = @"data source=(description=(address_list=(address=(protocol=tcp)(host=myhost)(port=1521)))(connect_data=(server=dedicated)(service_name=myservice)));user id=myuser;password=mypassword";             con.open();             oraclecommand command = con.createcommand();             command.commandtext = "select srvid mytable used=0 , rownum = 1";             oracledatareader reader = command.executereader();             while (reader.read())             {                 readercheck = reader.getstring(0);             } 

for whatever reason, reader.getstring(0) won't work because value it's trying access object of type system.data.oracleclient.oraclecommand.

if use reader.tostring() actualy returns "system.data.oracleclient.oraclecommand" string!

help appreciated!!

i found while searching solution same problem. getstring(0) won't work because you'll illegal cast error, because first element in reader decimal, won't cast directly string.

  reader.item(1).tostring 

or

  reader.getstring(1) 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -