No Data Exists? Weird field issue.

  • Thread starter Thread starter George Addison
  • Start date Start date
G

George Addison

Any idea why I am able to query an Access database OK,
but when I try to read field info from records that I
know are there I get an error that indicates: "No data
exists for the row/column"?

Is this a permissions error or a connection issue?

Here's my code:

Dim sConn As String
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
config.DBSource

Dim objConnection As OleDbConnection = New
OleDbConnection(sConn)
objConnection.Open()

Dim strSQL As String = "Select TOP 1 * FROM
tblUsers WHERE Username = '" & Replace(Trim
(Username), "'", "''") & "' AND Password = '" & Replace
(Trim(Password), "'", "''") & "'"
Dim objCommand As OleDbCommand = New OleDbCommand
(strSQL, objConnection)
Dim objDataReader As OleDbDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConnection)

If objDataReader.HasRows Then
While objDataReader.Read()
_ID = ID
_First = objDataReader("First")
_Last = objDataReader("Last")
_Username = objDataReader("Username")
_Password = objDataReader("Password")
_Email = objDataReader("Email")
_MembershipExpires = objDataReader
("Expires")
' e.g.: str = objDataReader
("DepartmentName")
End While
End If

objDataReader.Close()
objConnection.Close()
 
Back
Top