So I am working on my very first database and using vb.net and mysql. I have followed some guides on how to connect the two (http://www.dreamincode.net/forums/topic/115753-use-vbnet-to-connect-to-mysql/ for example). However, when I run the code, I get my error message of "Cannot connect to the database". Here is the code that I am having trouble with. Note that I have followed the guide to the letter (other than the connection string). I believe my issue is with that but I am not positive. Also my database is pretty basic at this point and is simply named "Database".
Imports MySql.Data.MySqlClient
Public Class MainMenu
Private Sub btnMultiple_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMultiple.Click
ProFab.Show()
End Sub
Private Sub btnSingle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSingle.Click
Dim MySqlConn As MySqlConnection
MySqlConn = New MySqlConnection()
MySqlConn.ConnectionString() = "database=Database"
Try
MySqlConn.Open()
MessageBox.Show("Connection to Database has been opened.")
MySqlConn.Close()
Catch ex As Exception
MessageBox.Show("Cannot connect.")
Finally
MySqlConn.Dispose()
End Try
SingleSearch.Show()
End Sub
End Class
catch ex ... messagebox.show(ex.ToString())