Micro Focus QTP (UFT) Forums
Database Checkpoint - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Database Checkpoint (/Thread-Database-Checkpoint)



Database Checkpoint - amilar - 01-13-2009

Hi All,

I have a problem in database checkpoint. I know how to do a database checkpoint. But I don’t know how it integrates or put it with a web application.

As an example, when I want to check search value with database value, how can I do it?. How do I connect database checkpoint with my search result window or grid.

If any one knows about any idea, please let me know. Thanks

regards,
Amila


RE: Database Checkpoint - Jackomcnabb - 01-20-2009

A Database check would be dependant on what you need to check.... is it the number of records being returned or the actual field name values?

What database are you connecting to? for examples of connection strings see: http://www.connectionstrings.com/

I have a control file that the Parameters are passed from I'm connecting to three different databases depending which on is switched on the control file on my test box.

Code:
DBType=GetLocalParameter("profile.database")  
If DBType="Oracle" Then
  UID = GetLocalParameter("oracle.user")
  PWD = GetLocalParameter("oracle.password")
  SERVER= GetLocalParameter("oracle.servername")
  set conn=Createobject("ADODB.Connection")
  Srvname="DRIVER={Microsoft ODBC for Oracle};UID="&UID&";PWD="&PWD&";SERVER="&SERVER&";"
  conn.open Srvname
Elseif DBType="sqlserver" Then
  UID = GetLocalParameter("sqlserver.user")
  PWD = GetLocalParameter("sqlserver.password")
  SERVER= GetLocalParameter("sqlserver.servername")
  DATABASE= GetLocalParameter("sqlserver.servername")
  DATASOURCE=GetLocalParameter("sqlserver.host")
  PORTNUM=GetLocalParameter("sqlserver.port")
  set conn=Createobject("ADODB.Connection")
  Srvname= "PROVIDER=SQLOLEDB;DATA SOURCE="&DATASOURCE&","&PORTNUM&";UID="&UID & ";PWD="&PWD&";DATABASE="
  conn.open Srvname
Elseif DBType="isam" Then
DATASOURCE=GetLocalParameter("isam.datasource")
set conn=Createobject("ADODB.Connection")
    Srvname="Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq="&DATASOURCE&"; "
msgbox(Srvname)
conn.open Srvname
End If

Once you have opened the connection to the server all you need to do is run the SQL query:

Code:
Set Rec = CreateObject("ADODB.Recordset")
SQL= ""&sqlstring&" "
Rec.open SQL ,conn


for me I'm just verifying the number of records being returned so my "sqlstring" is being built in another process and as it only returns the count you can put the count in a variable as below

Code:
Total_Count=rec(0)


Then you can do a compare with you database count and the number of records displayed on your Application..


RE: Database Checkpoint - amilar - 01-20-2009

Thanks,

I wrote a function for database connection and select query, but i can't retrieve data from the function. if u know the way please let me know... thanks.


my function



Code:
Function ConnectDatabase()
dim Cnxn,strCnxn
dim rsCus,strSQL

    set Cnxn = CreateObject("ADODB.Connection")
    set rsCus = CreateObject("ADODB.RecordSet")

strCnxn ="DRIVER={Microsoft ODBC for Oracle};UID=amilar12;PWD=mypass;SERVER=TEST_DB_DOMAIN.ORG"
    
    Cnxn.Open strCnxn
    msgbox "connect"


strSQL ="select  *  FROM aa_mgr.jms_messages "

rsCus.Open strSQL,Cnxn

end function


Regards,
Amila


RE: Database Checkpoint - Jackomcnabb - 01-20-2009

when you call the function you need to what variable that you are going to retrieve:

Code:
<VariableName>=<FunctionName>

my code is like this:

Code:
RecordNumbers = get_record_counts (PartialName, PartialNameCounty, PartialNameCity, IncludeAbbrev,Search_Level, Show_Full, Search_Method)