Timeout when using SQL Assistant (Microsoft.ApplicationBlocks.Data)

I am having problems with a timeout when working with long sql queries, a data set for which for long queries:

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

Where can I set the timeout, I use the Microsoft application block version 2.0.

+4
source share
1 answer

The SqlHelper data access application block SqlHelper been phased out in favor of the "database" , so you need to explicitly create a DbCommand and pass it to Database.ExecuteDataSet . You can then set the CommandTimeout property to override the default value of 30 seconds. for example, this sets a timeout of up to 200 seconds:

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

Source: https://habr.com/ru/post/1391281/


All Articles