2nd Post - No Data in Recordset Field

  • Thread starter Thread starter George Addison
  • Start date Start date
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()
 
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.)
 
Back
Top