Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.SqlClient
- Imports MySql.Data.MySqlClient
- Public Class Login
- Dim MySqlConnection As MySqlConnection
- Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
- MySqlConnection = New MySqlConnection
- MySqlConnection.ConnectionString = "server=localhost; port=3306; user id=root; password=; database=program;"
- MySqlConnection.Open()
- Dim Myadapter As New MySqlDataAdapter()
- Dim Command As New MySqlCommand
- Command.Connection = MySqlConnection
- Command.CommandText = "SELECT * FROM users WHERE username='" & UsernameTextBox.Text & "'AND password='" & PasswordTextBox.Text & "'"
- Myadapter.SelectCommand = Command
- Dim myData As MySqlDataReader
- myData = Command.ExecuteReader
- If myData.HasRows = 0 Then
- MsgBox("Error Wrong Login Info!")
- Else
- Form1.Show()
- Me.Close()
- End If
- End Sub
- Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
- Me.Close()
- End Sub
- Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement