1
我希望成功地允許用戶登錄後,將選定的記錄內容放入標籤,但這不起作用,我不知道如何解決它。如何從數據庫中的表中拉選定的數據
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
所以選擇當您正確輸入相匹配的記錄的電子郵件地址和密碼的記錄,但我怎麼拉戰績進入標籤的其他領域?那麼用戶的名字變成標籤等?
我收到錯誤「對象引用未設置爲對象的實例」。在Label5.Text = dbDataSet.Tables(「Selected Customers Details」)。行(0).Item(0) – user2177940