No Data Exists? Weird field issue.

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()
 

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,968
Messages
2,570,152
Members
46,698
Latest member
LydiaHalle

Latest Threads

Top