Reputation: 31
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?
Upvotes: 1
Views: 214
Reputation: 9394
You need to download the installation from MySql
There you'll get a driver for the mysql-database
Upvotes: 2
Reputation: 18569
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
Upvotes: 1