标题: 循环中调用数据库函数出错 [打印本页] 作者: xruiqi 时间: 2008-9-22 22:43 标题: 循环中调用数据库函数出错 For Rrow = 2 to EXCELrow + 1
msgbox xlSheet.cells(2,2)
CString = "DRIVER=SQL Server;SERVER=XIONGRQ\SQL2005;UID=saWD=Xiongruiqi123;APP=2007 Microsoft Office system;WSID=XIONGRQ;DATABASE=0623-QTP"
SeString = xlSheet.cells(Rrow,2)
set bbb = databaseFunction(CString,SeString)
ContractCode = bbb(0)
Browser("XXX").Page("XXX").Frame("ifrmGrid_2").WebElement("innertext:="&ContractCode,"html tag:=NOBR").Click
Browser("XXX").Page("XXX").Frame("Frame").Image("mnuDown").Click
Page("age").WebElement("mnu_rArrow").Click'点击删除
Message = Browser("xxx").Dialog("Microsoft Internet Explorer").Static("xxx!").GetROProperty("text")
If Message = xlSheet.cells(Rrow,1) Then
Reporter.ReportEvent 0,Message+"校验","通过(不能删除)"
Browser("xxx").Dialog("Microsoft Internet Explorer").WinButton("确定").Click
else
Reporter.ReportEvent 1,Message+"校验","失败(应该不能删除)"
End If
Rrow = Rrow +1
Next
CloseExcel(XL)
function databaseFunction(ConnectString,SelectString)
Dim cmd,sql,Res
Set Res = Createobject("adodb.recordset")
Set Cmd = Createobject("adodb.command")
Set Res = nothing
Set Cmd.activeconnection = nothing
Set Cmd = nothing
end function
Function OpenExcel(BooksName,SheetName,XlApp)
'Stracfile = PathFinder.Locate(BooksName)
Set XlApp = CreateObject("Excel.Application")
Set XlBook = XlApp.WorkBooks.Open(BooksName)
Set xlSheet = XLbook.Worksheets(SheetName)
xlApp.Visible = False
set OpenExcel = xlSheet
End Function
Function CloseExcel(XlApp)
XlApp.Activeworkbook.save
XlApp.Quit
Set XlBook = Nothing
Set XlApp = Nothing
End Function作者: sunqiang1024 时间: 2008-9-23 11:24
你看看你第二次执行循环时,从excel中取到sql语句了吗?作者: zte_boy 时间: 2008-9-24 12:13
先释放recordset对象