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

MySqlConnection.Open() Unhandled (no replies)

$
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, and I can't seem 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=db4free.net;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

Viewing all articles
Browse latest Browse all 1447

Trending Articles



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