2012-01-16 14 views
4

を使用した場合、長いクエリ用timesoutデータセットは以下のとおりです。タイムアウトの問題長いSQLクエリを扱うとき、私はタイムアウトの問題を抱えていたSQLヘルパー(Microsoft.ApplicationBlocks.Data)

私はタイムアウトを設定することができます
static public DataSet Getxxxx(Guid xxxx) 
{ 
    DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, "GetAllxx", new SqlParameter("@productxx", productxx)); 

    return ds; 
} 

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

答えて

3

データアクセスアプリケーションブロックSqlHelperphased out in favour of 'Database'されているので、あなたは明示的にDbCommandを作成し、Database.ExecuteDataSetにそれを通過する必要があります。 CommandTimeout propertyを設定して、デフォルトの30秒を無効にすることができます。例えばこれはタイムアウトを200秒に設定します。

using (DbCommand command = this.Database.GetStoredProcCommand("GetAllxx")) 
{ 
    Database.AddInParameter(command, "@productxx", DbType.Int32, productxx); 
    command.CommandTimeout = 200; 
    return Database.ExecuteDataSet(command); 
} 
+1

これはdbcommandまたはIDBbcommandです –