Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- ConnectToSQL()
- End Sub
- 'connecting to sql method
- Private Sub ConnectToSQL()
- Dim con As New MySqlConnection
- Dim cmd As New MySqlCommand
- Dim StudentId As String
- Dim StudentPassword As String
- Try
- If con.ConnectionString = "Data source= localhost; port=3306; database= Students; user=root; password=;" Then
- con.Open()
- cmd.Connection = con
- cmd.CommandText = "SELECT StudentId, StudentPassword, StudentName FROM members"
- Dim lrd As MySqlDataReader = cmd.ExecuteReader()
- If lrd.HasRows Then
- While lrd.Read()
- StudentId = lrd("StudentId").ToString
- StudentPassword = lrd("StudentPassword").ToString
- If StudentPassword = TextBox1.Text And StudentId = TextBox1.Text Then
- MsgBox("you logged in succesfully")
- Me.Hide()
- Form2.Show()
- TextBox1.Text = ""
- TextBox2.Text = ""
- End If
- End While
- Else
- MsgBox("Username and password do not match")
- TextBox2.Text = ""
- End If
- End If
- Catch ex As Exception
- MsgBox(ex.Message)
- Finally
- con.Close()
- End Try
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- TextBox1.Text = ""
- TextBox2.Text = ""
- TextBox1.Focus()
- End Sub
Add Comment
Please, Sign In to add comment