Imports MySql.Data.MySqlClient
Module IT_Services
Public sql As String
Public Con As New MySqlConnection
Public MyCommand As New MySqlCommand
Public drConnection As MySqlDataReader
Public dtConnection As DataTable
Public Sub Conn()
If Con.State = ConnectionState.Open Then Con.Close()
Sql = "Server=ชื่อ Server หรือ ไอพี;User Id=ยูสเซอร์ MySQL; Password=พาส MySQL; Database=ชื่อดาต้าเบส; Charset=utf8; Pooling=false"
Con = New MySqlConnection(Sql)
Con.Open()
End Sub
End Module
Dim objConn As New MySqlConnection
Dim objCmd As New MySqlCommand
Dim strConnString, strSQL As String
strConnString = "Server=localhost;User Id=root; Password=root; Database=database; Pooling=false"
objConn.ConnectionString = strConnString
objConn.Open()
Dim intNumRows As Integer
strSQL = "SELECT COUNT(*) FROM member WHERE Username = '" & Me.txtUsername.Text & "' AND Password = '" & Me.txtPassword.Text & "' "
objCmd = New MySqlCommand(strSQL, objConn)
intNumRows = objCmd.ExecuteScalar()
If intNumRows > 0 Then
Dim frm As New frmMain
frm._strUser = Me.txtUsername.Text
frm.LoadInfor()
frm.Show()
Me.Hide()
Else
MessageBox.Show("Username or Password Incorrect")
End If
objConn.Close()
objConn = Nothing