QuickTest Professional Connection Database query example __ Database

Source: Internet
Author: User

Just beginning to learn QTP, learn the example of database connection
The script is as follows:

Browser ("Test Login"). Page ("Test Login"). Webedit ("uname"). Click
Browser ("Test Login"). Window (People Selection-web dialog box). Page ("People selection"). Frame ("Contentleft"). Link ("Personnel department"). Click
Browser ("Test Login"). Window (People Selection-web dialog box). Page ("People selection"). Frame ("Basefrm"). Link ("Hoeven"). Click
Browser ("Test Login"). Window (People Selection-web dialog box). Page ("People selection"). Frame ("Botfrm"). Image ("btn_gb_on"). FireEvent "onmouseover"
Browser ("Test Login"). Window (People Selection-web dialog box). Page ("People selection"). Frame ("Botfrm"). Image ("btn_gb_on"). Click
Browser ("Test Login"). Page ("Test Login"). Webbutton ("Login"). Click
Browser ("Test Login"). Page ("Office automation System"). Frame ("Leftframe"). Link ("Official document Management"). Click
Browser ("Test Login"). Page ("Office automation System"). Frame ("leftframe_2"). Link ("In-Receipt management"). Click
Browser ("Test Login"). Page ("Office automation System"). Frame ("leftframe_2"). Link ("in-query"). Click
Browser ("Test Login"). Page ("Office automation System"). Frame ("MainFrame"). Webedit ("Oareceivebumf.bumfname"). Set "in-Test"
Browser ("Test Login"). Page ("Office automation System"). Frame ("MainFrame"). Image ("btn_cx_on"). FireEvent "onmouseover"
Browser ("Test Login"). Page ("Office automation System"). Frame ("MainFrame"). Image ("btn_cx_on"). Click
' DBTable ("Dbtable_4"). Output CheckPoint ("Dbtable_4")

Dim nn
Nn=datatable.globalsheet.getparameter ("P_text"). Value

Browser ("Test Login"). Page ("Office automation System"). Frame ("MainFrame"). Output CheckPoint ("78")
Dim mm
Mm=datatable.globalsheet.getparameter ("Mainframeoutput_text_out"). Value
Mm=datatable ("Mainframeoutput_text_out", Dtglobalsheet)
MsgBox mm

Dim Res,cmd,sql

Set res=createobject ("Adodb.recordset")
Set cmd=createobject ("Adodb.command")
Cmd.activeconnection= "driver={oracle in OraHome92}; Server=hkoracle; Uid=user; Pwd=zjlh;dbq=hkoracle;dba=w; apa=t; Exc=f; Xsm=default; fen=t; qto=t; frc=10; fdl=10; lob=t; rst=t; Btd=f; bam=ifallsuccessful; Num=nls;dpm=f; mts=t; Mdi=me; Csr=f; Fwc=f; fbs=60000; Tlo=o; "
Connecting Oracle Databases

Cmd.commandtype = 1
Sql= "SELECT COUNT (*) from OA_RECEIVEBUMF where bumfname as like '% in ' in test% '"//Fuzzy query, query name contains total number of "in-Test" records
Sql= "SELECT COUNT (*) from OA_RECEIVEBUMF where Bumfname= '" &nn& ""
Cmd.commandtext = sql
Set res = Cmd.execute ()

MsgBox Res (0)
If CStr (res (0)) = CStr (mm) Then//cstr converted to strings

Reporter.reportevent micpass, "test", "Query Success"//judgment is equal, equality output "query success"
Else
Reporter.reportevent micfail, "test", "Query failed"
End If

Set res = Nothing
Set cmd. ActiveConnection = Nothing
Set cmd= Nothing

Browser ("Test Login"). Page ("Office automation System"). Frame ("leftframe_2"). Link ("Logoff"). Click
Browser ("Test Login"). Page ("Test login _2"). Sync

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.