Function Authenticate(ByVal UserName As String, ByVal Password As String)
Dim con As New OleDbConnection(connectionstring)
Dim cmdstring As String
cmdstring = "SELECT username, password FROM tblUsers where username = @user AND password = @pass"
con.Open()
Dim cmd As OleDbCommand = New OleDbCommand(cmdstring, con)
cmd.Parameters.AddWithValue("@user", OleDbType.VarChar).Value = UserName
cmd.Parameters.AddWithValue("@pass", OleDbType.VarChar).Value = Password
Dim sdr As OleDbDataReader = cmd.ExecuteReader()
If (sdr.HasRows) Then
Authenticate = True
Else
Authenticate = False
End If
sdr.Close()
con.Close()
con = Nothing
Return Authenticate
End Function
A scalar variable '@user' needs to be declared
この行にヒットするとすぐに取得する理由がわからないのですが、誰でも助けてもらえますか:
Dim sdr As OleDbDataReader = cmd.ExecuteReader()