Excel VBA: ODBC SQL server driver query timeout expired

后端 未结 3 2012
轻奢々
轻奢々 2021-01-29 01:47

I have the below VBA query used in Excel 2016 that exacutes a MS Sql stored procedure, sometimes it executes smoothly and returns the recordset, but more often I get an error

3条回答
  •  梦如初夏
    2021-01-29 02:43

    One possible solution is to lengthen the connection command timeout value. Your current script has the value set to 0. This could be increased. Running the query in SSMS should give you a rough idea of the time needed to complete the query. Then, adjust the value accordingly.

        cm.CommandTimeout = 100
    

提交回复
热议问题