You are on page 1of 2

Private Sub btn_login_Click(ByVal sender As System.Object, ByVal e As System.Ev entArgs) Handles btn_login.

Click Try Dim cmds As New OleDbCommand("SELECT * FROM sys_staff WHERE stuser = '" & ComboBox1.SelectedItem & "'", con) Dim x As OleDbDataReader con.Open() x = cmds.ExecuteReader() x.Read() If ComboBox1.SelectedItem = x.Item("stuser") Then MsgBox("username is correct") If pass_txt.Text = x.Item("stpassw") Then MsgBox("password correct") Me.Hide() MDIParent1.Show() Else MsgBox("password incorrect") End If End If Catch MsgBox("no user") Dim x As String x = MessageBox.Show("Do you want to add new Staff user", "Confirm", MessageBoxButtons.YesNo) If x = vbYes Then Me.Hide() frm_adduser.Show() End If End Try con.Close() End Sub Private Sub frm_login_Load(ByVal sender As System.Object, ByVal e As System. EventArgs) Handles MyBase.Load File.SetAttributes(Application.StartupPath & "\MVS.mdb", FileAttributes. Hidden) Try Dim ds As New DataSet Dim dr As DataRow Dim dt As New DataTable Dim adptr As New OleDbDataAdapter("select * from sys_staff", con) adptr.Fill(ds, "stuser") dt = ds.Tables(0) ComboBox1.Items.Clear() For Each dr In dt.Rows ComboBox1.Items.Add(dr.Item("stuser")) Next Catch ex As Exception MsgBox("no user") Dim x As String x = MessageBox.Show("Do you want to add new Staff user", "Confirm", MessageBoxButtons.YesNo) If x = vbYes Then

Me.Hide() frm_adduser.Show() End If End Try End Sub

You might also like