Reputation: 81
I'm trying to connect aspx to a wamp database. Here's the database credentials:
Server: mysql_wampserver
user: sa
password: Passw0rd
computer: mypc
database: ProjetoUtilizadores
In my web.config i'm using the following:
<add key="cn" value="Server=localhost\mysql_wampserver;Database=ProjetoUtilizadores;User ID=sa;Password=Passw0rd;Trusted_Connection=False"/>
Whenever i try to connect i get the error "26 - Error Locating Server/Instance Specified" any help? Thank you.
NOTE: Firewall is currently disabled on the computer that i'm using either for VisualStudio or WAMP server.
EDIT: i tried with Server=localhost and Server=MY_IP and now i get
Named Pipes Provider, error: 40 - Could not open a connection to SQL ServeR
Upvotes: 0
Views: 1635
Reputation: 216361
If you connect to a MySql Server
you need to use the MySqlConnection
class and, of course, the same MySql version of every other ADO.NET classes (MySqlCommand, MySqlDataReader, MySqlDataAdapter).
So your code should be something like this....
using(MySqlConnection cnn = new MySqlConnection(GetConnectionStringFromConfig()))
{
using(MySqlCommand cmd = new MySqlCommand(commandText, cnn))
{
cnn.Open();
.......
}
}
These classes are available in the MySql .Net Connector.
The latest version could be downloaded here, after installation you need to add a reference to this library and add a using MySql.Data.MySqlClient;
directive to your project files where you use these classes.
Upvotes: 1