Page 1 of 1

compact framework timeou

Posted: Sat 05 Nov 2005 04:18
by npt
I'm having a problem with unstable internet access with the MySQLDirect Mobile connector. I understand that if something goes wrong in the MySqlConnection or MySqlCommand classes, an exception is thrown. The problem is that once that exception is thrown, the connection's state stays Open. I need a way to reset it, so I use connection.Close(). Unfortunately this takes forever before it is successfully executed.

Also if I do connection.Open() it takes forever if the internet isn't available. Here is the code in question. It takes a long time both at open and at close, much longer than the 1 second it's supposed to take. Any suggestions?

connection.UserId = user;
connection.Password = pass;
connection.Host = host;
connection.Port = 3306;
connection.Database = database;
connection.ConnectionTimeout = 1;
commander.CommandTimeout = 1;
//commander.
try{
connection.Open();
CoreLab.MySql.MySqlDataReader dataReader = commander.ExecuteReader();

while (dataReader.Read()) {
output.Text = dataReader.GetString(0);
}
dataReader.Close();

}
catch(Exception ex ){

output.Text = "Bad Internet" ;
}

connection.Close();

Posted: Tue 08 Nov 2005 09:00
by Serious
This is restriction of .NET Compact Framework that you cannot use MySqlCommand.CommandTimeout and MySqlConnection.ConnectionTimeout properties. This behavior will be documented.
If you get some exception for reason of internet errors you don't have to close connection. Just create new one.