in combobox how do can i select the user as student not other
e.g. if the user is student not Manager
Private Sub loginform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As New System.Data.OleDb.OleDbConnection()
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"
Try
Dim sqlcmd As String = "SELECT * FROM tbl_datain"
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sqlcmd)
sqlCom.Connection = conn
conn.Open()
Dim sqlRead As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()
While sqlRead.Read()
cbinfo.Items.Add(sqlRead("Personl").ToString)
End While
conn.Close()
Catch ex As Exception
End Try
End Sub
Private Sub cbinfo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbinfo.SelectedIndexChanged
Dim conn As New System.Data.OleDb.OleDbConnection()
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"
Try
Dim sqlcmd As String = "SELECT * FROM tbl_datain WHERE Personl ='" & cbinfo.Text & "'"
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sqlcmd)
sqlCom.Connection = conn
conn.Open()
Dim sqlRead As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader("Personl")
While sqlRead.Read()
txtname.Text = sqlRead.ToString("UserID")
txtpass.Text = sqlRead.ToString("PassWord")
cbinfo.Text = ""
txtname.Text = ""
cbinfo.Focus()
MessageBox.Show("Wong student")
End While
conn.Close()
Catch ex As Exception
End Try
End Sub