Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

.Net Web Service and .NET MySQL Connection Error (no replies)

$
0
0
I have a webservice on a hosting site that my company runs. We have a problem. I have a webservice that connects to a mysql database on another server.

Connection string in web.config (obviously xxx is replaced by real):

"Server=xxx.xxx.xxx.xxx;Port=3306;Database=xxxxxxx;Uid=xxxxxx;Pwd=XXXXXXXX;"


The code:

sqlStmt = "SELECT count(*) FROM users"

private void executeSqlDbCommand(string connStr, string sqlStmt)
{
MySqlConnection myConnection = new MySqlConnection();
MySqlCommand myCommand = new MySqlCommand();
int i = 0;

try
{
myConnection = new MySqlConnection(connStr);
myCommand = new MySqlCommand(sqlStmt, myConnection);
myConnection.Open();
i = myCommand.ExecuteNonQuery();
myConnection.Close();
}
catch (Exception ex)
{
writeError(ex, true);
}
finally
{
if ((!object.ReferenceEquals(myCommand, System.DBNull.Value)))
{
myCommand.Dispose();
}

if ((!object.ReferenceEquals(myConnection, System.DBNull.Value)))
{
if (myConnection.State != System.Data.ConnectionState.Closed)
{
myConnection.Close();
myConnection.Dispose();
}
}
}
}

Works fine on my local machine.
Works fine on another server.
Connection information works great with php and ODBC from that server so it isn't a port.
Does not work on the hosted server.

I initially got this error but upgraded to the latest .net mysql.data.dll (6.6.6)

Unknown server error Unable to connect to any of the specified MySQL hosts.

Now I am getting this error:

The type initializer for 'MySql.Data.MySqlClient.MySqlPoolManager' threw an exception

HELP ME! So frustrated!

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>