How to extend the timeout of a SQL query

前端 未结 6 1825
没有蜡笔的小新
没有蜡笔的小新 2021-02-11 14:21

This is not a connection timeout as a connection to the database is made fine. The problem is that the stored procedure that I\'m calling takes longer than, say, 30 seconds and

6条回答
  •  执笔经年
    2021-02-11 14:40

    I think this might be a better way to do this (as of Enterprise Library 6.0):

    SqlDatabase db = new SqlDatabase(connectionManager.SqlConnection.ConnectionString);
    System.Data.Common.DbCommand cmd = db.GetStoredProcCommand(storedProc, parameterValues);
    cmd.CommandTimeout = 600;
    return db.ExecuteScalar(cmd);
    

提交回复
热议问题