Professional Documents
Culture Documents
Imports MySql.Data.MySqlClient
Module connection
Public cn As New MySqlConnection("Server=localhost; userid=root; password=;
database=YourDatabaseName")
Public cmd As New MySqlCommand
Public da As New MySqlDataAdapter
Public dt As New DataTable
Public dr As MySqlDataReader
Dim i As Integer = 0
cn.Open()
With cmd
.Connection = cn
.CommandText = "SELECT * from tblUsers where username ='" & txtusername.Text & "' and
password='" & txt_password.Text & "'"
End With
dr = cmd.ExecuteReader
dr.Read()
If dr.HasRows Then
Me.Hide()
'MsgBox("Welcome!", MsgBoxStyle.Information, "Successful Login")
nextform.Show()
Else
MsgBox("Incorrect Username and Password", MsgBoxStyle.Critical, "Login")
End If
cn.Close()