查看完整版本: QTP的数据库操作

man16181 2008-8-28 09:46

QTP的数据库操作

[size=10.5pt][font=宋体][/font][/size][size=10.5pt][/size]
[size=10.5pt][/size]
[table][tr][td=1,1,568][size=10.5pt]       Set Conn = CreateObject("ADODB.Connection")[/size][size=10.5pt][/size]
[size=10.5pt]       Conn.open "Descrīption=plssvr;DRIVER=SQL Server;SERVER=PLSSVR;UID=sa;PWD=;APP=WinRunner;WSID=WANGW;DATABASE=PLS"[/size][size=10.5pt][/size]
[size=10.5pt]       Set Rs = CreateObject("ADODB.Recordset")[/size][size=10.5pt][/size]
[size=10.5pt]       sql="select * from dim_currencytype where currencytype_no= '" & CurrNo & "'"[/size][size=10.5pt][/size]
[size=10.5pt]       Rs.open sql,Conn,1,3[/size][size=10.5pt][/size]
[/td][/tr][/table][size=10.5pt][/size]
[size=10.5pt]       [font=宋体]备注:[/font][/size][size=10.5pt][/size]
[size=10.5pt]       rs.Open sql,conn,1,1[font=宋体]无法看到其他用户添加的新数据,但被其他用户删除的数据将变为不可访问,同时可以看到其他用户所作的修改。[/font][/size][size=10.5pt][/size]
[size=10.5pt]       rs.Open sql,conn,1,3[font=宋体]静态打开方式。在你使用数据是其他用户无法访问该数据[/font][/size][size=10.5pt][/size]
[size=10.5pt]       rs.Open sql,conn,1,2[font=宋体]动态的数据库打开方式,其他用户所进行的修改、删除和新建等工作都会立即在数据对象中体现出来,并且支持全部类型的数据移动方式,除非提供者不支持,否则也可以进行书签操作[/font][/size][size=10.5pt][/size]
[size=10.5pt]       rs.Open sql,conn,-1[font=宋体]不指定打开方式[/font][/size][size=10.5pt][/size]
[size=10.5pt]       [font=宋体]这是一个对数据库查询的一段代码,还要关闭数据库[/font][/size][size=10.5pt][/size]
[size=10.5pt]       qtp[font=宋体]访问EXCEL文件 [/font][/size][size=10.5pt][/size]
[table][tr][td=1,1,568][size=10.5pt]       Set conn= createobject("ADODB.Connection")[/size][size=10.5pt][/size]
[size=10.5pt]       Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=C:\test_data.xl*;**tended Propertie*='**cel 8.0;hdr=yes'"[/size][size=10.5pt][/size]
[size=10.5pt]       Set res= createobject("ADODB.Recordset")[/size][size=10.5pt][/size]
[size=10.5pt]       res.Open "select *  from [nbu_ini_reg$]  " ,conn,2,2[/size][size=10.5pt][/size]
[size=10.5pt]       If res.eof=false Then[/size][size=10.5pt][/size]
[size=10.5pt]         answer_assumpsit=res("[font=宋体]回访约定")[/font][/size][size=10.5pt][/size]
[size=10.5pt]         first_code =res("[font=宋体]初审员代码")[/font][/size][size=10.5pt][/size]
[size=10.5pt]       End If[/size][size=10.5pt][/size]
[/td][/tr][/table][size=10.5pt][/size]
[size=10.5pt][/size]
页: [1]
查看完整版本: QTP的数据库操作