For i=1 to Datatable.GetRowCount
Dialog("Login").WinEdit("Agent Name:").Set DataTable("username", dtGlobalSheet)
Dialog("Login").WinEdit("Password:").Set DataTable("passwd", dtGlobalSheet)
Dialog("Login").WinButton("OK").Click
datatable.GlobalSheet.SetNextRow
Next
Function writeorderno(orderno)
Dim fso, myfile,username,passwd
Set fso=CreateObject("scrīpting.FileSystemObject")
Set myfile=fso.openTextFile("C: esting.txt",1,false)
tmp=split(myfile.readline,",")
username=tmp(0)
passwd=tmp(1)
myfile.close
End Function
写文本文件的代码
Function writeorderno(orderno)
Dim fso, myfile
Set fso=CreateObject("scrīpting.FileSystemObject")
Set myfile=fso.openTextFile("C:
esult1.txt",8,false)
myfile.writeline orderno
myfile.close
End Function
3.EXCEL文件
我们可以把EXCEL文件当成数据文件,通过对EXCEL文件的读写操作,来实现数据驱动.
可以把EXCEL文件当作对象的方式来完成写的操作
Dim Excel,ExcelSheet
Set Excel=CreateObject("Excel.Application")
Set ExcelSheet=CreateObject("Excel.Sheet")
ExcelSheet.Application.visible=true
ExcelSheet.ActiveSheet.Cells(1,1).value=1
ExcelSheet.ActiveSheet.Cells(1,2).value=2
ExcelSheet.ActiveSheet.Cells(1,3).value=3
Excel.Save "C: est.xls"
Set ExcelSheet=Nothing
用ADO的方式连接EXCEL文件来做读的操作
Dim conn,input,filename
filename="D:公基本情况(tb_gsgk)-标准格式.xls" '
Set conn= createobject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Persist Security Info=False;Data Source="&filename&";Extended Properties='Excel 8.0;hdr=yes'"
Set input= createobject("ADODB.Recordset")
input.Open "select * from [公基本情况-标准格式$] " ,conn,2,2
input.close
Set input=nothing
Dim res,cmd,sql
Set Res=createobject("adodb.recordset")
Set Cmd=createobject("adodb.command")
Cmd.activec ‘连接数据库数据源,需要修改
Cmd.CommandType = 1
sql="selec t * from 表 where name=username"
Cmd.CommandText = sql
Set res = Cmd.Execute()
Set res = nothing
Set cmd.ActiveConnection = nothing
Set Cmd= nothing
Dim conn
set conn=Createobject("ADODB.Connection")
Dim Srvname
Srvname="DSN=Dblis50;UID=sa; PWD=;APP=QuickTest Professional;WSID=ADMIN;DATABASE=Dblis50" ‘连接数据库数据源,需要修改
conn.connectionstring = Srvname
conn.Open
Dim Rec
Set Rec = CreateObject("ADODB.Recordset")
Dim SQL
SQL="select top 1 * from Lis_List"
Rec.open SQL ,conn
Dim Username
Username=Rec.fields("PatName")
Msgbox Username
利用SQL connection访问
Dim conn,res,cmd,sql,strconn
set conn=Createobject("adodb.connection")
Set Res=createobject("adodb.recordset")
Set Cmd=createobject("adodb.command")
strconn="DSN=Dblis50;UID=sa; PWD=;APP=QuickTest Professional;WSID=ADMIN;DATABASE=Dblis50" ‘连接数据库数据源,需要修改
conn.connectionstring = strconn
conn.Open
Cmd.Activeconnection= conn
Cmd.CommandType = 1
sql="select top 2 * from Lis_List"
Cmd.CommandText = sql
Set res = Cmd.Execute()
Dim Username
Username=res.fields("PatName")
Msgbox Username
Set res = nothing
Set cmd.ActiveConnection = nothing
Set Cmd= nothing