2nd Post - No Data in Recordset Field

G

George Addison

I'm able to query an Access database on my server
(remote), and I can even successfully get the number of
records returned in my recordset. BUT when I try to
access a field value, I get an error indicating that an
instance is required (referring to the recordset).

Can anyone point me in a direction?

-------------------------

Dim sConn As String
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
config.DBSource & ";Password=myPass;"
Dim conn As OleDbConnection = New OleDbConnection
(sConn)
conn.Open()

Dim strSQL As String = "Select TOP 1 * FROM
tblUsers WHERE Username = 1"
Dim objCommand As OleDbCommand = New OleDbCommand
(strSQL, conn)
Dim objDataReader As OleDbDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConnection)

System.Web.HttpContext.Current.Trace.Warn("field
value", objDataReader("ID"))
objDataReader.Close()
conn.Close()
 
S

Steve C. Orr [MVP, MCSD]

You must use objDataReader.Read to position the pointer to the first record.
(Then you must use it again to advance to each subsequent record.)
 

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

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top