Visual Basic 6.0 + Sql Server存储过程超时问题

时间:2012-11-22 15:10:11

标签: sql-server-2005 vb6

爵士 我正在使用vb6.0和sql server 2005.我写了一个小程序,它在sql server中返回立即结果但在vb 6.0中它返回超时。任何身体的任何想法?请帮帮忙?

我的程序:

Alter procedure
[dbo].[SpRptSalesDayBookSummary](@liComid integer,@liPerid integer,@ad_dtfrm DateTime,@ad_dtto DateTime)
AS
begin   
SET NOCOUNT ON;
Select SaleDate,Sum(Grand) as tot
from SalesMaster a,SalesDet b 
Where a.id=b.RefId 
    And a.CompanyId= @liComid 
    And a.PeriodId=@liPerid  
    And a.SaleDate Between @ad_dtfrm And @ad_dtto
Group By SaleDate Order By SaleDate 
End

我的vb代码:

Dim cmd As New ADODB.Command
    Dim rs1 As New ADODB.Recordset
    Dim param2 As ADODB.Parameter
    Dim param3 As ADODB.Parameter
    Dim param4 As ADODB.Parameter
    Dim param5 As ADODB.Parameter

    g_objData.DBConn.CursorLocation = adUseClient
    Set cmd.ActiveConnection = g_objData.DBConn
    cmd.CommandType = adCmdStoredProc
    cmd.CommandText = "SpRptSalesDayBookSummary"
    Set param2 = cmd.CreateParameter("Input", adInteger, adParamInput)
    cmd.Parameters.Append param2
    param2.value = 20
    Set param3 = cmd.CreateParameter("Input", adInteger, adParamInput)
    cmd.Parameters.Append param3
    param3.value = 8
    Set param4 = cmd.CreateParameter("Input", adDate, adParamInput)
    cmd.Parameters.Append param4
    param4.value = Format(PD_DtFrm, "yyyy-mm-dd")
    Set param5 = cmd.CreateParameter("Input", adDate, adParamInput)
    cmd.Parameters.Append param5
    param5.value = Format(PD_DtTo, "yyyy-mm-dd")

    Set rs1 = cmd.Execute

请帮忙。

1 个答案:

答案 0 :(得分:0)

您没有说出针对Connection对象的.CommandTimeout属性是什么,但您可能需要更新它。我确信您也可以针对命令对象指定.CommandTimeout属性 - 尝试将其设置为600(10分钟)。

我之前看过代码,在几秒钟内就连接设置CommandTimeout属性,认为是几分钟!