QTP轻量级框架系列(五)之oracle查询数据

上一篇 / 下一篇  2016-03-24 18:35:29 / 个人分类:QTP

'==========================================================================

' NAME: Database processing

' AUTHOR: heyl 

' DATE  : 2013-07-12

' COMMENT: 

'==========================================================================

Class Db_procs

'PopBox Processing

sub PopBox(Prompt,intSecond,strTitle)

         dim obj

         set bj = createobject("WScript.Shell")

         obj.Popup Prompt,intSecond,strTitle

         set bj=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


TAG: 数据库 Oracle oracle QTP qtp

 

评分:0

我来说两句

日历

« 2024-03-29  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 22601
  • 日志数: 13
  • 建立时间: 2011-08-15
  • 更新时间: 2017-11-22

RSS订阅

Open Toolbar