VB6.0 如何调用存储过程,返回结果集问题
对于VB6.0这个软件,估计对于现在很多程序员来说,都不知道啥软件来了,但本人还在摸,
If rs.BOF And rs.EOF Then
MsgBox "There is no master FR connect setting, please contact IT."
Exit Sub
Else
frConnectStr = rs("DESCRIPTION")
End If
If frCn.State = adStateOpen Then
frCn.Close
Set frCn = Nothing
End If
frCn.CursorLocation = adUseServer 'adUseClient 'adUseServer
frCn.IsolationLevel = adXactReadCommitted
frCn.CommandTimeout = 1800
frCn.Open frConnectStr
' Dim cmd As ADODB.Command
' Set cmd = New ADODB.Command
' cmd.CommandText = "dbo.FR_GEN_DATA_FOR_AGPO"
' cmd.CommandType = adCmdStoredProc
' cmd.ActiveConnection = frCn
' cmd.CommandTimeout = 300
' With cmd.Parameters
' .Append cmd.CreateParameter("@JOSTR", adVarChar, adParamInput, 4000, "20G04502DE01,20G07345GB01,")
' .Append cmd.CreateParameter("@Character", adVarChar, adParamInput, 1, "C")
' .Append cmd.CreateParameter("@DayPeriod", adInteger, adParamInput, , 7)
' End With
' Set rsFr = cmd.Execute
' Debug.Print cmd.State
sql = "exec dbo.FR_GEN_DATA_FOR_AGPO '20G04502DE01,20G07345GB01,', 'C',7"
Set rsFr = frCn.Execute(sql)
Debug.Print rsFr.State
If rsFr.State = 1 Then
Debug.Print rsFr.RecordCount
If rsFr.BOF And rsFr.EOF Then
MsgBox "There is no mapping data in FR."
Else
Do While Not rsFr.EOF
Debug.Print rsFr(0)
rsFr.MoveNext
Loop
End If
'Get JO, by G or C
End If
记得存储过程,要补上一个 SET NOCOUNT ON, 原理不详~~~囧