'select from the database and connections to the database using mysql'
Try
Dim myConnection As String = "datasource=localhost;password=;database=pis;username=root;"
Dim mycon As MySqlConnection = New MySqlConnection(myConnection)
Dim SelectCommand As MySqlCommand = New MySqlCommand("Select * from pis.user where usertype='" & TextBox2.Text & "' and PassWord='" & TextBox1.Text & "';", mycon)
Dim myReader As MySqlDataReader
mycon.Open()
myReader = SelectCommand.ExecuteReader()
Dim mozzy As String = Status(TextBox2.Text, TextBox1.Text)
If mozzy = "Admin" Then
Timer1.Start()
ProgressBar1.Show()
Label22.Show()
ElseIf mozzy = "Doctor" Then
Timer3.Start()
ProgressBar1.Show()
Label22.Show()
Else
Timer2.Start()
ProgressBar1.Show()
Label22.Show()
End If
mycon.Close()
Catch ex As Exception
End Try
End Sub
'function that gets the inputs that the user inputs and matches it with data in the database'
Function Status(ByVal usertype As String, ByVal password As String)
Dim status1 As String = Nothing
Dim CurrentRow As Integer = 0
Try
Dim constring As String = "datasource=localhost;port=3306;username=root;database=pis;"
Dim conDatabase As MySqlConnection = New MySqlConnection(constring)
Dim cmdDatabase As MySqlCommand = New MySqlCommand("SELECT *FROM `user` WHERE `usertype` ='" & usertype & "' AND `password` = '" & password & "';", conDatabase)
Dim sda As MySqlDataAdapter = New MySqlDataAdapter()
sda.SelectCommand = cmdDatabase
Dim db As DataTable = New DataTable()
sda.Fill(db)
status1 = db.Rows(CurrentRow)("usertype")
conDatabase.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Return status1
End Function