I've been having this problem for over a week now and I want to fix it. Everytime I try to connect to my MySQL Database I keep on getting this error:A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
* I downloaded and Imported the latest MySQL Connector for VB.NET
* I Enabled all IP/TCP Connections
* I Enabled all Remote Connections
* I Disabled Firewall and Anti-Virus Systems
* I'm using the latest Connection String
Could someone please help me? Here's my code:
Imports System.Data.SqlClient
Public Class LoginForm1
Dim conn As SqlConnection
'TODO: Insert code to perform custom authentication using the provided username and password
'(See http://go.microsoft.com/fwlink/?LinkId=35339).
'The custom principal can then be attached to the current thread's principal as follows:
'My.User.CurrentPrincipal = CustomPrincipal
'where CustomPrincipal is the IPrincipal implementation used to perform authentication.
'Subsequently, My.User will return identity information encapsulated in the CustomPrincipal object
'such as the username, display name, etc.
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
conn = New SqlConnection
conn.ConnectionString = "Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;"
Try
conn.Open()
MsgBox("Connected!")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Also I'm using Host Gator for the MySQL Database. I wanna know if I'm using the right server name in host gator. I used the IP Address in the bottom left corner of cPanel of host gator. I also put a % in the whitelist remote connection.
解决方案I'm guessing you've seen these/been all over their tech help ?
http://support.hostgator.com/articles/cpanel/how-to-connect-to-the-mysql-database-remotely[^]
http://support.hostgator.com/articles/cpanel/how-to-connect-to-the-mysql-database-remotely[^]
To start with, I'd put something like the MySQL Workbench on your local machine to help management of your database and check connectivity - once you get the connectivity correct from there, you can then add it to the connection string of a program, which brings me to this ...
you don't show the connection string you used - but it looks like its trying to find a local DB (named pipes) rather than across the network with tcp/udp .. so, please indicate your connection string (update your answer)
btw, I couldn't find anything on their site about how a connection string to their hosted db's is put together, so I hope you have more information
'g'
Solution Solved!
I finally got it connected thanks guys ROOKIE MISTAKE LOL
I forgot to add the references of MySQL. I added the DLL's but I forgot to add the references!
I also changed the imports to "Imports MySql.Data.MySQLClient" and changed the every Sql coding to MySQL! I guess it was using Microsoft SQL Server instead of MYSQL!