Dim conn As MySqlConnection
'connect to DB
conn = New MySqlConnection()
conn.ConnectionString = "server=**จจ**จจ.com; user id=****จจจ***; password=***จจจ**จจ**; database=**จจ**จจ**จจ"
'see if connection failed.
Try
conn.Open()
Catch myerror As MySqlException
MsgBox("Error:" & myerror.ToString)
End Try
'sql query
Dim myAdapter As New MySqlDataAdapter
Dim sqlquery = "SELECT * FROM login WHERE username='" + txtuser.Text + "' AND password= '" + txtpass.Text + "'"
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'start query
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader()
'see if user exists
If myData.HasRows = 0 Then
MsgBox("Invalid username and/or password!")
Else
MsgBox("Login Accepted!")
Form2.Show()
Me.Hide()
End If
i got this error:MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. ---> System.Exception: Exception of type 'System.Exception' was thrown.
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at Go_For_Code_Share.Form1.Button1_Click_1(Object sender, EventArgs e) in C:\Users\Arno Cornette\AppData\Local\Temporary Projects\Go For Code Share\Form1.vb:line 15
Hope you can help
Thanks
Arno Cornette

New Topic/Question
Reply



MultiQuote






|