4

長い sql クエリを処理するときにタイムアウトの問題が発生しています。長いクエリのタイムアウトになるデータセットは次のとおりです。

static public DataSet Getxxxx(Guid xxxx)
{
    DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, "GetAllxx", new SqlParameter("@productxx", productxx));

    return ds;
}

Microsoft アプリケーション ブロック バージョン 2.0 を使用しています。

4

1 に答える 1

3

データ アクセス アプリケーション ブロックSqlHelperは 'Database' を優先して段階的に廃止されたため、 を明示的に作成してDbCommandに渡す必要がありますDatabase.ExecuteDataSet。次に、CommandTimeoutプロパティを設定して、デフォルトの 30 秒をオーバーライドできます。たとえば、これはタイムアウトを 200 秒に設定します。

using (DbCommand command = this.Database.GetStoredProcCommand("GetAllxx"))
{
    Database.AddInParameter(command, "@productxx", DbType.Int32, productxx);
    command.CommandTimeout = 200;
    return Database.ExecuteDataSet(command);
}
于 2012-01-16T15:53:11.253 に答える