Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient
Public Class LoginForm1.vb
' TODO: Insert code to perform custom authentication using the provided username and password
' (See http://go.microsoft.com/fwlink/?LinkId=35339).
' The custom principal can then be attached to the current thread's principal as follows:
' My.User.CurrentPrincipal = CustomPrincipal
' where CustomPrincipal is the IPrincipal implementation used to perform authentication.
' Subsequently, My.User will return identity information encapsulated in the CustomPrincipal object
' such as the username, display name, etc.
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= cartoon-thai.tk;Port= 80; user id= cartoontha_kingmembers; password= themrlong; database= cartoontha_king"
MySqlConnection.Open()
Dim Myadapter As New MySqlDataAdapter
Dim sqlquary = "Select * From Users WHERE Username='" & UsernameTextBox.Text & "'AND Password='" & PasswordTextBox.Text & "';"
Dim command As New MySqlCommand
command.Connection = MySqlConnection
command.CommandText = sqlquary
Myadapter.SelectCommand = command
Dim Mydata As MySqlDataReader
Mydata = command.ExecuteReader
If Mydata.HasRows = 0 Then
MsgBox("Error! Wrong Login Information")
Else
MySqlConnection.Close()
Me.Close()
Form1.Show()
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