DataReader And SQL Server
VB Code:
Dim objConnection As New SqlClient.SqlConnection _
("server=.;database=ndbs;trusted_connection=true")
Dim objCommand As New SqlClient.SqlCommand _
("Select * From tblUsers", objConnection)
Dim objReader As SqlClient.SqlDataReader
' Open the database connection
objConnection.Open()
' Put the results in the DataReader object
objReader = objCommand.ExecuteReader
Do While objReader.Read
If objReader.Item("password") = "password" Then
Response.Write("The Password Is Password")
End If
Loop
objReader.Close()
objConnection.Close()
End Sub
The problem I have is that when I use the following :
VB Code:
If objReader.Item("password") = "password" Then
Response.Write("The Password Is Password")
End If
It just does not recognize that I am trying to compare the strings. It is so frustrating, if I do a response.write(objReader.Item("password")) whilst the datareader.read loop goes around then it does display the information that the DataReader pulls from the sql database.
Is it because the DataReader is read-only????
Any ideas?????
Cheers,
Matt.