Link to home
Create AccountLog in
Avatar of isischen
isischen

asked on

I couldn't get the value of a column at a specific ordinal from a datareader.

Something worked for me the last time around ---  myrow(mycold1) = autoreader.GetValue(2)
but now, it,autoreader.getvalue(2), only return the column name.  
What I want is the content of the datareader's column returned from a datareader.read() method.
If I try to use datareader.getstring(2), I got a 'cast' exception.

Using autoreader As System.Data.OleDb.OleDbDataReader = selectCmd.ExecuteReader()
                        autoreader.Read()
                        myrow = _DtText.NewRow()
                        myrow(mycol) = autoreader.GetValue(2)

Open in new window

Avatar of raja_ind82
raja_ind82
Flag of India image

try this...

autoreader.fields(0).value

Regards,
M.Raja
ASKER CERTIFIED SOLUTION
Avatar of rachitkohli
rachitkohli
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
rachitkohli  is correct.  sorry,  my answer is working only in VB.