ADO.net のラッパーとして機能する「データベース」クラスがあります。たとえば、プロシージャを実行する必要がある場合は、Database.ExecuteProcedure(procedureName, parametersAndItsValues) を呼び出します。
SQL Server 2000 のデッドロック状況で深刻な問題が発生しています。私たちのチームの一部は、これらのイベントを最小限に抑えるために SQL コードとトランザクションに取り組んでいますが、このデータベース クラスをデッドロック状況に対して堅牢にすることを考えています。
デッドロックの被害者に、おそらく少し遅れてから再試行してもらいたいのですが、それが可能かどうかはわかりません。使用するメソッドのコードは次のとおりです。
public int ExecuteQuery(string query)
{
int rows = 0;
try
{
Command.Connection = Connection;
Command.CommandType = CommandType.Text;
if(DatabaseType != enumDatabaseType.ORACLE)
Command.CommandText = query;
else
Command.CommandText ="BEGIN " + query + " END;";
if (DatabaseType != enumDatabaseType.SQLCOMPACT)
Command.CommandTimeout = Connection.ConnectionTimeout;
if (Connection.State == ConnectionState.Closed)
Connection.Open();
rows = Command.ExecuteNonQuery();
}
catch (Exception exp)
{
//Could I add here any code to handle it?
throw new Exception(exp.Message);
}
finally
{
if (Command.Transaction == null)
{
Connection.Close();
_connection.Dispose();
_connection = null;
Command.Dispose();
Command = null;
}
}
return rows;
}
この処理を catch ブロック内で行うことはできますか?