Link to home
Start Free TrialLog 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
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
rachitkohli  is correct.  sorry,  my answer is working only in VB.