Untitled40 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

Recommended Answers

All 5 Replies

What happens if you supply the IP address as part of the server name? For example, on my regular computer my SQL Server instance is

JIM-PC\SQLEXPRESS

But I imagine (I can't verify this because my computer is in the shop) I could also use

\\192.168.1.104\SQLEXPRESS

Are you using VS2012 Express, if so you may be out of luck.

Click Here

No, I'm using VS2012 Pro

I don't use either VS2012 or MySql, but based on their support forum, it looks like a lot of people have had issues with this configuration. Do you have the the latest vesion of Connector/Net installed? Based on this: Click Here, the newer releases should offer full VS2012 support.

As a possible workaround, have you tried connecting through ODBC instead?

Problem reesolved, I had to download a new driver.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.