0
Im mit MySql.Data auf C# und eine INSERT-Abfrage eine Ausnahme wirft:C# MySql Timeout abgelaufen
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at MySql.Data.MySqlClient.ExceptionInterceptor.Throw(Exception exception)
at MySql.Data.MySqlClient.MySqlConnection.Throw(Exception ex)
at MySql.Data.MySqlClient.MySqlConnection.HandleTimeoutOrThreadAbort(Exception ex)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
at WarehouseMgr.SyncServiceLib.RequestCreator.CreateRequest(RequestPackage package, MySqlConnection db, ILog log, ConfigFile config, String log_prefix) in z:\WORKSPACE\Web\W_WarehouseMgr\WebApp\SyncService_Library\RequestCreator.cs:line 229
at WarehouseMgr.SyncServiceLib.InputWork.InputWorker.RunWorkOnce() in z:\WORKSPACE\Web\W_WarehouseMgr\WebApp\SyncService_Library\InputWork\InputWorker.cs:line 152
Irgendwelche Ideen?
Edit:
Der Code für die INSERT-Abfrage:
var reqId = 0;
var reqSql =
"INSERT INTO `requests` (`uid`, `label_id`, `corridor_id`, `status`) VALUES (@p_uid, @p_label_id, @p_corridor_id, 'waiting');" +
"SELECT `id` FROM `requests` WHERE uid = @p_uid LIMIT 1;";
using (var cmd = new MySqlCommand(reqSql, db)) {
cmd.Parameters.AddWithValue("@p_uid", package.RequestUid);
cmd.Parameters.AddWithValue("@p_label_id", labelId);
cmd.Parameters.AddWithValue("@p_corridor_id", corridorId);
using (var reader = cmd.ExecuteReader()) {
if (reader.Read()) {
reqId = reader.GetInt32("id");
}
}
}
if (reqId <= 0) {
log.E(TAG, log_prefix + "Request creation failed");
throw new Exception("Request creation failed");
}
Es sagt Ihnen genau, was der Fehler ist ... Aus irgendeinem Grund ist Ihre Abfrage Timeout. Vielleicht hat etwas anderes eine Sperre auf dem Tisch, in den Sie einfügen, oder vielleicht stimmt etwas mit Ihrer insert-Anweisung nicht. Schwer zu sagen, ohne Ihren vollen Code zu sehen. – mituw16
Mögliches Duplikat von [MySql.Data.MySqlClient.MySqlException: Timeout abgelaufen] (http://stackoverflow.com/questions/3475867/mysql-data-mysqlclient-mysqlexception-timeout- expired) –
Andere Abfrage läuft gut? Also bezieht sich das Problem nur auf diese INSERT-Anweisung? –