我正在努力避免发生超时情况。目前,脚本在测试环境中运行100%,但一切都在本地运行。因此,现在安装在实时环境中,确实需要更长的时间。但是它会出现VB超时默认设置为30秒。然而,与SQL不同,我不熟悉VB,因此我不确定设置它的代码。目前的代码如下:
Dim strFile As String
Dim strCon As String
Dim strSQL As String
Dim dateRows As Variant
Dim i As Integer
Dim today As Date
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
strFile = Workbooks(1).FullName
strCon = "Provider=SQLOLEDB.1; Data Source=ABC;Initial catalog=ABC;Integrated Security=ABC;"
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
range1 = Sheets("Line data ( Do not alter )").Range("AA9")
cn.Open strCon
strSQL = "Select "order by userid, appointmentdate "
rs.Open strSQL, cn
Sheets("Line data ( Do not alter )").Range("AA9").CopyFromRecordset rs
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub
我发现代码表明comm.CommandTimeout = 10,但不确定把它放在哪里..
任何帮助表示感谢。