有人可以帮助我吗?我在登录时遇到了一些问题。当我尝试登录时,我收到错误“多步 OLE DB 操作生成错误。检查每个 OLE DB 状态值(如果可用)。没有完成任何工作。” - 结合 ExecuteScalar 检索。
提前感谢您提供的任何帮助,您可能会或可能无法给我。
Protected Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
If String.IsNullOrWhiteSpace(txtUsername.Text) Then
Invalid()
Exit Sub
End If
Using con As New OleDbConnection(connectionString)
Dim cmd As New OleDbCommand("Select count(*) From tblAccounts where Username = ?", con)
cmd.Parameters.AddWithValue("Username", txtUsername)
con.Open()
If CType(cmd.ExecuteScalar(), Integer) > 0 Then
cmd.CommandText = "Select CPassword From tblAccounts Where Username = ?"
Dim matches As String = CType(cmd.ExecuteScalar(), String)
If matches = Sha1(txtPassword.Text) Then
Response.Redirect("main.aspx")
Else
Invalid()
End If
Else
Invalid()
End If
End Using
End Sub