我希望在成功允许用户登录后将选定的记录内容放入标签中,但这不起作用,我不知道如何修复它。
Public dbName As String = "DB.accdb"
Public dbConnexStr As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & dbName
Public dbConnector As OleDbConnection = New OleDbConnection(dbConnexStr)
Public SQL_Str As String
Public dbCommand As OleDbCommand
Public dbDataSet As DataSet = New DataSet("DataSetWJECComp")
Public dbDataAdapter As OleDbDataAdapter
Public dbSource As BindingSource
Public dbCommandBuilder As OleDbCommandBuilder
Private Sub BtnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
If LoginDetailsSearch() = True Then
dbDataAdapter = New OleDbDataAdapter(SQL_Str, dbConnector)
dbDataAdapter.Fill(dbDataSet, "Selected Customer Details")
Label5.Text = dbDataSet.Tables("Selected Customers Details").Rows(0).Item(0)
Else
MsgBox("The E-Mail address or password you entered is not valid, please check your entries and try again.", MsgBoxStyle.Critical, "Error")
End If
End Sub
Function LoginDetailsSearch() As Boolean
dbConnector.Open()
SQL_Str = "SELECT count(UserID) FROM Table_UserDetails WHERE EmailAddress ='" & txtEmail.Text & "' AND UserPassword = '" & txtPassword.Text & "'"
Dim LoginCommand = New OleDbCommand(SQL_Str, dbConnector)
Dim RecordFinder = LoginCommand.ExecuteScalar
LoginDetailsSearch = (1 = CStr(RecordFinder))
dbConnector.Close()
End Function
因此,当您正确输入与记录匹配的电子邮件和密码时,它会选择一条记录,但是如何将记录的其他字段拉入标签?那么用户的名称变成标签等?