我也在这里添加C#组,因为这不是VB问题,但ExecuteNonQuery给出了超时。如何增加超时?
完全错误消息:错误[HYT00] [Microsoft] [ODBC SQL Server驱动程序]超时已过期
我们有cms系统,在CMS中我创建了一个IFRAME,它调用这个ASPX + VB代码,它位于不同的physicall文件夹中,并且它管理了Pipeline Classic。
当我在Old应用程序中运行它时它工作正常。但我将页面复制到新闻服务器并创建新的应用程序池/网站调用OldASPPAGES我在下面的'ExecuteNonQuery()'函数上获得ODBC超时。
有时候我会工作但是10个案例中的9个我得到了。我检查了记录,有247条记录。但是在下面你看到每个循环组成2个sql语句。 (更新和插入)... 2 x 247记录=约。 500条记录。
但是由于sql语句是一致的,所以1调用ExecuteNonQuery,executue确实做了500个SQL语句....
我知道这是垃圾,是不可接受的......但是我暂时继承了这一点,我无法改写它。
重点:
以下是原始状态:我刚刚添加: conn.ConnectionTimeout = 240 正如你所看到的,我已经增加了240秒,但是我在大约时间后仍然会有超时。 30秒...所以这不是正确的地方......
问题: - 为什么这个语句在旧的ASP环境中工作(没有问题),而不是在IFRAME的这个环境中....
有人可以建议吗?
感谢
Private Function data30bis_save(ByVal data_30bis_list, ByVal user_id)
lblMessage.Text = "data30bis_save"
Dim conn As OdbcConnection, cmd As OdbcCommand, ra As Integer, sql As String, data_30bis As Attest30bis.Data30bisCobonet
' important: always purge the old situation before loading the new one !
data30bis_cleanup(user_id)
conn = New OdbcConnection("dsn=chris2;uid=xxx;pwd=ssddddd;")
conn.ConnectionTimeout = 240
conn.Open()
sql = ""
lblMessage.Text = "st"
For Each data_30bis In data_30bis_list
sql = sql & "update usr_codes set "
If Len(data_30bis.analyseDate) > 0 Then
sql = sql & "a30b_analysedate=convert(datetime,'" & data_30bis.analyseDate.ToString & "',103)"
Else
sql = sql & "a30b_analysedate=getdate()"
End If
sql = sql & ", a30b_errorcode=" & data_30bis.errorCode
sql = sql & ", a30b_inputcompanyidvalid=" & Abs(CInt(data_30bis.inputCompanyIdValid))
sql = sql & ", a30b_inputnossvalid=" & Abs(CInt(data_30bis.inputNossValid))
sql = sql & ", a30b_noss=" & data_30bis.noss
sql = sql & ", a30b_reservecontractorconcept=" & Abs(CInt(data_30bis.reserveContractorConcept))
If Len(data_30bis.reserveContractorDate) > 0 Then
sql = sql & ", a30b_reservecontractordate=convert(datetime,'" & data_30bis.reserveContractorDate.ToString & "',103)"
Else
sql = sql & ", a30b_reservecontractordate=getdate()"
End If
sql = sql & ", a30b_reservemakingconcept=" & Abs(CInt(data_30bis.reserveMakingConcept))
If Len(data_30bis.reserveMakingDate) > 0 Then
sql = sql & ", a30b_reservemakingdate=convert(datetime,'" & data_30bis.reserveMakingDate.ToString & "',103)"
Else
sql = sql & ", a30b_reservemakingdate=getdate()"
End If
sql = sql & ", a30b_date_modified=getdate()"
sql = sql & " where user_id='" & user_id & "' and no_tva='" & data_30bis.companyId & "' and cd_pays_tva = 'BE'"
sql = sql & vbCrLf
' 2nd SQL
sql = sql & "insert a30b_controles (dt_ctrl, user_id, cd_pays_tva, no_tva, no_societe, a30b_analysedate, a30b_errorcode, a30b_inputcompanyidvalid, a30b_inputnossvalid, "
sql = sql & "a30b_noss, a30b_reservecontractorconcept, a30b_reservecontractordate, a30b_reservemakingconcept, a30b_reservemakingdate, a30b_companyId) "
sql = sql & "values (getdate(),'" & user_id & "','FR','massif',''," & "convert(datetime,'" & data_30bis.analyseDate.ToString & "',103)"
sql = sql & "," & data_30bis.errorCode & "," & Abs(CInt(data_30bis.inputCompanyIdValid)) & "," & Abs(CInt(data_30bis.inputNossValid)) & "," & data_30bis.noss & "," & Abs(CInt(data_30bis.reserveContractorConcept))
sql = sql & ",convert(datetime,'" & data_30bis.reserveContractorDate.ToString & "',103)," & Abs(CInt(data_30bis.reserveMakingConcept))
sql = sql & ",convert(datetime,'" & data_30bis.reserveMakingDate.ToString & "',103)," & data_30bis.companyId & ")"
sql = sql & vbCrLf
Next
lblMessage.Text = sql
cmd = New OdbcCommand(sql, conn)
ra = cmd.ExecuteNonQuery()
lblMessage.Text = "ssssst"
conn.Close()
cmd = Nothing
conn = Nothing
lblMessage.Text = "ssssat"
Return ra
End Function
答案 0 :(得分:1)
lblMessage.Text = sql
cmd = New OdbcCommand(sql, conn)
cmd.CommandTimeout= 200
ra = cmd.ExecuteNonQuery()
lblMessage.Text = "ssssst"
答案 1 :(得分:0)
您是否尝试过Command类的CommandTimeout属性?
但是,这只是症状修复。你不能调整你的查询,使其更高效吗?