51Testing软件测试论坛
标题:
【seagull1985-QTP】oracle数据库查询
[打印本页]
作者:
seagull1985
时间:
2016-3-23 19:33
标题:
【seagull1985-QTP】oracle数据库查询
'==========================================================================
' NAME: Database processing
' AUTHOR: heyl
' DATE : 2013-07-12
' COMMENT:
'==========================================================================
Class Db_procs
'PopBox Processing
sub PopBox(Prompt,intSecond,strTitle)
dim obj
set obj = createobject("WScript.Shell")
obj.Popup Prompt,intSecond,strTitle
set obj=nothing
end sub
'Create database link
Function CreOraLink(provider,userid,passwd,dataip,strsql,columnname)
Dim Cnn,strCnn
strCnn ="Provider="&provider&";Password="&passwd&";Persist Security Info=True;User ID="&userid&";Data Source="&dataip
Set Cnn = CreateObject("adodb.Connection")
Cnn.Open strCnn
If Cnn.State = 0 Then
Call PopBox("创建数据库链接失败",30,"数据库链接")
End If
'Generate the recordset object
Set Rs = CreateObject("ADODB.Recordset")
'excute sql
Rs.Open strsql,Cnn,1,3
'if you want judge the database state,must define(DS_dbrc) a global variable in QTP
DS_dbrc = Rs.Recordcount
if DS_dbrc <> 0 Then
DS_dbvalue = Rs(columnname)
if DS_dbvalue <> "" Then
DS_dbvalue = Cstr(DS_dbvalue)
End if
else
DS_dbvalue = ""
End if
Rs.close
Set RS=nothing
Cnn.Close
Set Cnn=nothing
End Function
End Class
' Dim DS_dbvalue
' Set DBP = new Db_procs
' ttt = "select * from HPSTJNL_CHECKED"
' Call DBP.CreOraLink("MSDASQL.1","mast","mast","10.211.16.120",ttt,0)
' msgbox DS_dbvalue
' ttt = "select * from HPSTJNL"
' Call DBP.CreOraLink("MSDASQL.1","mast","mast","10.211.16.120",ttt,"txn_cd")
' msgbox DS_dbvalue
复制代码
作者:
fhhh_eyou
时间:
2016-3-24 09:25
学习中,谢谢
作者:
赵佳乐SMILE
时间:
2016-3-24 18:02
棒棒哒
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2