Imports System.Security.Cryptography Imports MySql.Data.MySqlClient Public Class LoginForm1 Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click Me.Close() End Sub Dim MySqlConnection As MySqlConnection Private Function StringtoMD5(ByVal Content As String) As String Dim M5 As New System.Security.Cryptography.MD5CryptoServiceProvider Dim ByteString() As Byte = System.Text.Encoding.ASCII.GetBytes(Content) ByteString = M5.ComputeHash(ByteString) Dim FinalString As String = Nothing For Each bt As Byte In ByteString FinalString &= bt.ToString("x2") Next Return FinalString End Function Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click PasswordTextBox.Text = StringtoMD5(PasswordTextBox.Text) MySqlConnection = New MySqlConnection MySqlConnection.ConnectionString = "Server=****;Database=****;Uid=****;Pwd=****;" MySqlConnection.Open() Dim Myadapter As New MySqlDataAdapter Dim sqlquary = "SELECT * FROM table_name 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("Sorry! We can't find your Username and Password. Try Again or contact us on the forum") Else Form1.Show() Me.Close() End If End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)