本帖最后由 dz138 于 2011-12-2 16:02 编辑
有存储过程名: WIBF_Summary, 有参数 @year , @Month 主要用于数据筛选输出记录集$Cnn=ObjCreate("ADODB.Connection")
$Cnn.open("DRIVER={SQL Server};SERVER="&$sServer&";UID="&$susername&";PWD="&$spassword&";Database="&$sdatabase)
$Rs=ObjCreate("ADODB.Recordset")
$Comm = ObjCreate("ADODB.Command") ;建一个command对象
With $Comm
.ActiveConnection = $Cnn
.CommandText = "WIBF_Summary" ;定义command 对象调用名称,即存储过程名称
.CommandType = 4 ;设置command调用类型是存储过程
.Prepared = True ;将SQL命令先行编译
.Parameters.Append (.CreateParameter("@Year",3,1,4,$TYear))
.Parameters.Append (.CreateParameter("@Month",3,1,4,$TMonth))
EndWith
$Rs = $Comm.Execute
$x=1
While Not $RS.eof and Not $RS.bof
If @error = 1 Then ExitLoop
if $x=1 then
Local $oExcel = _ExcelBookNew()
For $i = 1 To $colcount ;Loop
_ExcelWriteCell($oExcel, $Rs.Fields($i-1).name,$x, $i )
Next
$x=$x+1
endif
For $i = 1 To $colcount ;Loop
_ExcelWriteCell($oExcel, $Rs($i-1).value,$x, $i )
Next
$x=$x+1
$rs.movenext
wend
;endif
msgbox(0,"完成","完成!")
$Rs.close
$Cnn.close
=============================================
无法返回记录集, 求高手解答, 谢谢!! |