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