hi
i'm struggling to read data from database
i created a table with 5 rows as for Login form
username and password
i would like to have access to forms when i enter password and username of department 1
it shows department 1 but when i enter password and username for department 2 it still showing department 1
i need help!!!!!!
here is my code
Imports System.Data.SqlClient
Public Class Frmlogin
Private Sub BtnLogin_Click(sender As Object, e As EventArgs) Handles BtnLogin.Click
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
con.ConnectionString = "Data Source=OCHO_CINCO;Initial Catalog=CGHMS;Integrated Security=True"
cmd.Connection = con
con.Open()
cmd.CommandText = "select log_username, log_password from login where log_username = '" &
TxtUsername.Text & "' and log_password='" & Txtpassword.Text & "'"
dr = cmd.ExecuteReader
If dr.HasRows Then
MessageBox.Show("Ekurhuleni")
FrmDashBoardMenuDept1.Show()
Me.Hide()
ElseIf dr.HasRows Then
MessageBox.Show("West Rand")
FrmDashBoardMenuDept2.Show()
Me.Hide()
Else
MessageBox.Show("Invalid Username and Password")
End If
con.Close()