0
myConnection = new SqlConnection("user id=champion3_test;" +
                                       "password=test;server=10.168.1.58;" +
                                       "Trusted_Connection=true;" +
                                       "database=champion3_sabdb; " +
                                       "connection timeout=30");

This code gives the error:

Thrown: "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)" (System.Data.SqlClient.SqlException) Exception Message = "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)", Exception Type = "System.Data.SqlClient.SqlException", Exception WinRT Data = ""    

Here are some screenshots that might help with debugging of my server's settings: https://i.sstatic.net/QJ476.jpg

I know that 'champion3_test' is a valid user id 'test' is a valid password for champion3_test the database name is 'champion3_sabdb'

1
  • for starters you should not create the SqlConnection like this. I would highly suggest putting this in a config file there are plenty examples on google on how to configure / Database ConnectionString in a App.Config file Commented Mar 13, 2013 at 15:08

2 Answers 2

4

SQL server isn't MySQL. If you are using MySQL, download the MySQL .NET Connector and use their connection class, MySqlConnection.

To learn how to use the MySQL Connector, you can start here.

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

Comments

0

You can download the MySql Connector for .Net here.

Once you've installed the driver, you can connect using the MySql Connector classes:

 string connStr = "server=localhost;user=root;database=world;port=3306;password=******;";
 MySqlConnection conn = new MySqlConnection(connStr);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.