1,105,380 Community Members

MySQL on Remote Server

Member Avatar
Ancient Dragon
Achieved Level 70
27,580 posts since Aug 2005
Reputation Points: 5,231 [?]
Q&As Helped to Solve: 3,028 [?]
Skill Endorsements: 115 [?]
Team Colleague
Featured
Sponsor
 
0
 

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
Attachments
Member Avatar
Reverend Jim
Noli mentula
5,394 posts since Aug 2010
Reputation Points: 746 [?]
Q&As Helped to Solve: 643 [?]
Skill Endorsements: 51 [?]
Moderator
Featured
 
0
 

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
Member Avatar
TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418 [?]
Q&As Helped to Solve: 152 [?]
Skill Endorsements: 16 [?]
 
0
 

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

Click Here

Member Avatar
Ancient Dragon
Achieved Level 70
27,580 posts since Aug 2005
Reputation Points: 5,231 [?]
Q&As Helped to Solve: 3,028 [?]
Skill Endorsements: 115 [?]
Team Colleague
Featured
Sponsor
 
0
 

No, I'm using VS2012 Pro

Member Avatar
TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418 [?]
Q&As Helped to Solve: 152 [?]
Skill Endorsements: 16 [?]
 
0
 

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?

Member Avatar
Ancient Dragon
Achieved Level 70
27,580 posts since Aug 2005
Reputation Points: 5,231 [?]
Q&As Helped to Solve: 3,028 [?]
Skill Endorsements: 115 [?]
Team Colleague
Featured
Sponsor
 
0
 

Problem reesolved, I had to download a new driver.

Question Answered as of 1 Year Ago by TnTinMN and Reverend Jim
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article