Imports System.Data
Imports MySql.Data.MySqlClient
Public Class frmLogin
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim objConn As New MySqlConnection
Dim objCmd As New MySqlCommand
Dim dtAdapter As New MySqlDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Dim strConnString, strSQL As String
strConnString = "Server=;User Id=; Password=; Database=; Pooling=false"
strSQL = "SELECT * FROM member WHERE Username = '" & Me.txtUsername.Text & "' AND Password = '" & Me.txtPassword.Text & "' "
objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds)
dt = ds.Tables(0)
If dt.Rows.Count > 0 Then
If dt.Rows(0)("Status").ToString.ToLower.Equals("vip") Then
MsgBox("Wellcome VIP member")
Form3.Show()
Else
MsgBox("Wellcome User Member")
Form2.Show()
Me.Hide()
End If
Else
MsgBox("Username or Password Incorrect")
End If
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
If MessageBox.Show("Exit application?", "", MessageBoxButtons.YesNo) = DialogResult.Yes Then
Application.Exit()
End If
End Sub
End Class
Imports System.Security.Cryptography
Imports System.Text
Public Function MD5(ByVal strString As String) As String
Dim ASCIIenc As New ASCIIEncoding
Dim strReturn As String
Dim ByteSourceText() As Byte = ASCIIenc.GetBytes(strString)
Dim Md5Hash As New MD5CryptoServiceProvider
Dim ByteHash() As Byte = Md5Hash.ComputeHash(ByteSourceText)
For Each b As Byte In ByteHash
strReturn = strReturn & b.ToString("x2")
Next
Return strReturn
End Function