I am looking to put the selected records contents into Labels after successfully allowing a user to login, however this is not working and I am not sure how to fix it.
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
So it selects a record when you correctly enter a email and password which matches a record, however how do I pull the other fields of the record into labels? So the Name of the user into a label etc?
Yo have spelled your table name wrong: Selected Customer Details and Selected Customer* s * Details. I recommend you declare it as a string and substitute this variable name instead of typing it out twice.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.