Connection String for MySQL in C#.Net2.0
-
Connection Terminated unexpectedly. I would like to add here that now I have installed a local MySQL Server and restored one of the table to fetch data form it. But still I am not able to connect to the database locally also from C#.Net2.0 :(. When the code reaches to mySQLCon.open(), then it fires the above exception. Connection String:"Server=localhost; PORT=80; Data Source=ecampust_opensis; User Id=root; Password=;" Thanks
-
Show us the code fragment you are using to access the connection string, and the code fragment you use to open the connection to the DB. (Not the whole program, please, just the relevant bits)
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Web.Config: Containing the connection string Fetching the Connection string into a string connStr and opening the connection: connStr = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]; mySQLCon = new MySqlConnection(connStr); mySQLCon.Open();
-
Show us the code fragment you are using to access the connection string, and the code fragment you use to open the connection to the DB. (Not the whole program, please, just the relevant bits)
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Now the exception is coming as: {MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts ---> System.Net.Sockets.SocketException: The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for
-
Now the exception is coming as: {MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts ---> System.Net.Sockets.SocketException: The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for
Check your database server: Do you have the Named Pipes protocol enabled in the Network setup? (apparently .NET Sockets likes both Named Pipes and TCP/IP) Also check your firewall at the server - it may be rejecting port 80.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
Web.Config: Containing the connection string Fetching the Connection string into a string connStr and opening the connection: connStr = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]; mySQLCon = new MySqlConnection(connStr); mySQLCon.Open();
My guess is that you have the wrong port number. Port 80 is normally reserved for HTTP traffic (web browsers/servers).
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Check your database server: Do you have the Named Pipes protocol enabled in the Network setup? (apparently .NET Sockets likes both Named Pipes and TCP/IP) Also check your firewall at the server - it may be rejecting port 80.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Hey dear Griff, I would like to ask you here that "As MySQL is open source and there are many articles for connecting the .Net application with MySQL db, and no where I have found that someone have specified this Named Pipes protocol thing in order to connect to MySQL dB although I have checked firewall. As our client is the owner of the MySQL Database, I think some dB level permission is to be granted in order to access the dB remotely. What do you say dear Griff on this? Thanks
-
My guess is that you have the wrong port number. Port 80 is normally reserved for HTTP traffic (web browsers/servers).
A guide to posting questions on CodeProject[^]
Dave KreskowiakHey Dave, I am checking the connection locally, so i think the port must be 80 (for all local servers).
-
Hey Dave, I am checking the connection locally, so i think the port must be 80 (for all local servers).
The port number has nothing to do with the server being local or not.
Varun Sareen wrote:
so i think the port must be 80
"Thinking" is not allowed in this business. You either know what the port is, or you have to find out.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
The port number has nothing to do with the server being local or not.
Varun Sareen wrote:
so i think the port must be 80
"Thinking" is not allowed in this business. You either know what the port is, or you have to find out.
A guide to posting questions on CodeProject[^]
Dave KreskowiakOk Dave, Thanks
-
Check your database server: Do you have the Named Pipes protocol enabled in the Network setup? (apparently .NET Sockets likes both Named Pipes and TCP/IP) Also check your firewall at the server - it may be rejecting port 80.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Hey dear Griff, the error is coming as "Connection unexpectedly terminated". I am just going sick over this issue :(. Kindly help someone.