มันเออเร่อประมาณนี้เลยครับ รันแบบใส่ localhost รันได้ไม่มีปันหา แต่รันแบบใส่ IP เข้าไป ไม่ได้เลยครับ
Code
Private Sub bttlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttlogin.Click
Dim objConn As New MySqlConnection
Dim objCmd As New MySqlCommand
Dim strConnString, strSQL, strNUMANDDATE, strTIMETOLOCK, dbserver, dbid, dbpassword, dbname As String
dbserver = frmconnectdatabase.txtserverdatabase.Text
dbid = frmconnectdatabase.txtiddatabase.Text
dbpassword = frmconnectdatabase.txtpassworddatabase.Text
dbname = frmconnectdatabase.txtdbname.Text
strConnString = "Server = '" & dbserver & "' ; User Id = '" & dbid & "' ; Password = '" & dbpassword & "' ; Database = '" & dbname & "' ; Pooling = false"
objConn.ConnectionString = strConnString
objConn.Open()
Dim checkid As Integer
Dim checkcomanddate As Integer
Dim i As Integer
i = TimeOfDay.Hour
If i Mod 2 = 0 Then
strTIMETOLOCK = i
Else
strTIMETOLOCK = i - 1
End If
strSQL = "SELECT COUNT(*) FROM member WHERE Username = '" & Me.txtusername.Text & "' AND Password = '" & Me.txtpassword.Text & "' AND member_id = '" & Me.txtmemberid.Text & "'"
objCmd = New MySqlCommand(strSQL, objConn)
checkid = objCmd.ExecuteScalar()
strNUMANDDATE = "SELECT COUNT(*) FROM book WHERE book_no = '" & Me.lblnum.Text & "' AND book_date = '" & Format(Now, "yyyy-MM-dd") & "' AND member_id = '" & Me.txtmemberid.Text & "' AND book_hour = '" & strTIMETOLOCK & "'"
objCmd = New MySqlCommand(strNUMANDDATE, objConn)
checkcomanddate = objCmd.ExecuteScalar()
If checkid > 0 Then
If checkcomanddate > 0 Then
Me.Hide()
tmlockwindow1.Start()
tmmessage1.Start()
Else
MessageBox.Show(" คุณไม่ได้จองเครื่องคอมพิวเตอร์ในช่วงเวลาดังกล่าว ")
End If
Else
MessageBox.Show(" ชื่อผู้ใช้งาน , รหัสผ่าน หรือรหัสประจำตัวไม่ถูกต้อง ")
End If
objConn.Close()
objConn = Nothing
txtusername.Clear()
txtpassword.Clear()
txtmemberid.Clear()
End Sub