2

先生,我正在使用 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

请帮忙。

4

1 回答 1

0

您没有说明 .CommandTimeout 属性对 Connection 对象的作用,但您可能需要提高它。我相信您也可以针对命令对象指定 .CommandTimeout 属性 - 尝试将其设置为 600(10 分钟)。

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

于 2013-01-15T18:50:26.480 回答