Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

MySqlConnection.Open() Unhandled? Visual Basic. (1 reply)

$
0
0
Hi,
I started writing a basic project that logs you in via data stored on a MySQL Database, and returns with a new form. I'm using the MySQL connector for it, and it's pretty basic, but I can't get around this error :\

Here's the Code:

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
MySqlConnection = New MySqlConnection
MySqlConnection.ConnectionString = "server=mysql17.000webhost.com;Port=3306; user id=xxx; password=xxx; database=xxx"
MySqlConnection.Open()

Dim MyAdapter As New MySqlDataAdapter
Dim sqlquary = "SELECT * From users 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("ERROR: Wrong Login Information, Try again!", MsgBoxStyle.Critical, "ERROR")
Else
Form1.Show()
Me.Hide()
End If
End Sub


It Looks right to me, What do you think might be the problem here?

Thanks! Any help greatly appreciated :)

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>