Below is my code for login page I would like to show login user detail on home.
For login my code works properly but does not show currently login user show following error "NO data exists for column/row".

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Login.Click
RetrieveUserPass()
End Sub




' User id and password checking function

Public Sub RetrieveUserPass()
Try
Dim dbConn As OleDbConnection
Dim dbCommand As New OleDbCommand
Dim conn As New OleDbConnection

dbConn = New OleDbConnection(cnSettings())
dbCommand.CommandText = "SELECT * FROM [table1] Where User_id = '" & user_id.Text & "' And [password] = '" & password.Text & "'"

dbCommand.Connection = dbConn
dbConn.Open()

Dim dbDR As OleDb.OleDbDataReader = dbCommand.ExecuteReader

'Condition fail

If Not dbDR.HasRows Then
Login_fail.Show()
Login_fail.user_id.Clear()
Login_fail.Password.Clear()
Login_fail.user_id.Focus()
Me.Hide()
Else

'Condiion true

Home.Show()
Me.Hide()
Home.Label2.Text = dbDR("user_no")
End If

dbConn.Close()

Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")
End Try
End Sub

Edited 3 Years Ago by happygeek: fixed formatting

Public Sub RetrieveUserPass()
Try
Dim dbConn As OleDbConnection
Dim dbCommand As New OleDbCommand
Dim conn As New OleDbConnection

dbConn = New OleDbConnection(cnSettings())
dbCommand.CommandText = "SELECT * FROM [table1] Where User_id = '" & user_id.Text & "' And [password] = '" & password.Text & "'"

dbCommand.Connection = dbConn
dbConn.Open()

Dim dbDR As OleDb.OleDbDataReader = dbCommand.ExecuteReader

If dbDR.Read then 
	With Home
		.label2.text  = userid.text
		.show
	End With 
Me.Dispose
Else 
MessageBox.show("Error: user does not exist")
End If 

dbConn.Close()

Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")
End Try
End Sub

Edited 5 Years Ago by Netcode: n/a

With Home
.label2.text = userid.text
.show
End With

This is working but problem is that it retrives from frant end not from back end and I want from bcoz any user enter username like vASIM then it has to show as Vasim but right it is showing as vASIM

This is working but problem is that it retrives from frant end not from back end and I want from bcoz any user enter username like vASIM then it has to show as Vasim but right it is showing as vASIM

Then you also need to validate the case of the username in your database.

I used user name only for example. If I want to retrive except user name then then I have to retrive from database.For this purpose I need help.

In a login form, what else is there to retrieve apart from the username.You can only do a validation against the entered username and password and if it exists, you retrieve the username and display which is exactly what we just did. Except you mean something else which i don't get

Edited 5 Years Ago by Netcode: n/a

Can you please specify what you want to display and where (table) is it stored?
You might retrieve everything in your initial select and then use Netcode's with to assign the required values that you've read from the db.

I want to show employee's every details like first name, middle name, last name ,date of birth etc. And all this details are store in the table1.mdb

This article has been dead for over six months. Start a new discussion instead.