1

I need your help on this one.

I got the error message which is stated:

"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 was trying to connect other local computer local host using ip. My code:

 public DbStudent() { UGIcon = new SqlConnection(); UGIcon.ConnectionString = "server= IPAddress;user="id";password="pass";database=MyDB"; } public SqlConnection Open() { UGIcon.Open(); return UGIcon; } public void Close() { UGIcon.Close(); } 

Could somebody help me out please?

5
  • 4
    Your title has MySql and your error is about SQL Server, are you trying to connect to MySQL database using SqlConnection ? Commented Mar 11, 2013 at 8:00
  • Yes,is it possible? or can you give me the other way to connect mysql? Commented Mar 11, 2013 at 8:02
  • I don't understand how your code may compile : your connection string contains unescaped quotes... Commented Mar 11, 2013 at 8:03
  • Your code is even can't compiled...The connection string should be "server= IPAddress;user=id;password=pass;database=MyDB" Commented Mar 11, 2013 at 8:05
  • i'm sorry if i cause the confusion. although i'm just the beginner on it, actually i still quite don't understand. Commented Mar 11, 2013 at 8:06

2 Answers 2

2

You need to download the installation from MySql

There you'll get a driver for the mysql-database

Sign up to request clarification or add additional context in comments.

Comments

1

The SqlConnection is used to access SQL Server, for another database use OleDbConnection. So, if you want connect to MySQL use OleDbConnection instead.

 public DbStudent() { UGIcon = new OleDbConnection(); UGIcon.ConnectionString = "Server=IPAddress;Database=MyDB;Uid=id;Pwd=pass;"; } 

You can see here for MySQL Connection String

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.