I'm trying to figure out how to add a new connection to MySQL running on a different computer on my network. When I click Project --> New Data Source a list of drivers appears, but none of them are MySQL (see thumbnail) which I have previously installed. I'm using 64-bit Windows 7. The MySQL database is on a computer running 64-bit Windows 8.
I found a tutorial that works (see code below) with a console program, but I want to use Dataset
Imports System.Data Imports MySql.Data.MySqlClient Module Module1 Private con As New MySqlConnection Private cmd As New MySqlCommand Private reader As MySqlDataReader Private _host As String = "<ip address here>" ' Connect to localhost database Private _user As String = "<user name here>" 'Enter your username, default is root Private _pass As String = "<password here>" 'Enter your password Sub Main() Dim oConn As String oConn = "Server=""" + _host + """;User Id=""" + _user + """;Password=""" + _pass + """;" con = New MySqlConnection(oConn) Try con.Open() 'Check if the connection is open If con.State = ConnectionState.Open Then con.ChangeDatabase("dvd_collection") 'Use the MYSQL database for this example Console.WriteLine("Connection Open") Dim Sql As String = "SELECT title,date_format(release_date,""%Y-%m-%d"") as Date FROM movies" cmd = New MySqlCommand(Sql, con) reader = cmd.ExecuteReader() 'Loop through all the users While reader.Read() Console.WriteLine("Title: " & reader.GetString(0)) 'Get the host Console.WriteLine("Release Date: " & reader.GetString(1)) 'Get the username End While End If Catch ex As Exception Console.WriteLine(ex.Message) ' Display any errors. End Try Console.ReadKey() End Sub End Module
Edited 4 Years Ago by Ancient Dragon