.Net Web Service and .NET MySQL Connection Error
Posted by: Linda Rawson
Date: December 09, 2013 11:33AM

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!

Options: ReplyQuote


Subject
Written By
Posted
.Net Web Service and .NET MySQL Connection Error
December 09, 2013 11:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.