Click here to Skip to main content
15,877,384 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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  
    ' 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;"
        Catch ex As Exception
        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.
Updated 9-Nov-14 14:46pm
dan!sh 9-Nov-14 19:46pm    
Is it MySql or MSSql? You are using standard .Net connector for MS SQL in your code.
Member 11219665 9-Nov-14 20:02pm    
I'm using MySql and great what do I need to do?

I'm guessing you've seen these/been all over their tech help ?[^][^]

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

Share this answer
Member 11219665 9-Nov-14 20:48pm    
I used a MySql Connection string... I can even give you the link to the latest one if you want... "Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;" <--- This is just a standard connection string to MySql.
Garth J Lancaster 9-Nov-14 20:55pm    
ok, so, what value did you substitute for 'myServerAddress'
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!
Share this answer
Garth J Lancaster 9-Nov-14 21:38pm    
cool !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900