Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QTP Database conenction and parameterization of the values
#1
Solved: 11 Years, 4 Months ago Smile 
Hi Ankur and All,

I have made a connection to Access database from QTP using database query wizard with the manually option and entered the sql statement too .here are 5rows in the database and i want to fetch the values from all the rows to the data table of the qtp under only one row in QTP and run the script for 1st iteration and then 2 nd . I am able to fetch the data for 1 st row into data table but for the 2 nd one it is posting beside the 1 st one .but I need to put the 2 nd data under the same 1 st row as we parameterize the data .Can you help me

You can see the attachement too .It clearly describes all the one by one procedure .
Reply
#2
Solved: 11 Years, 4 Months ago
Get the number of rows in the database and set the number in a variable. Now use a for loop, fetch the first record, put it in the datatable and increment the datatable rowcount ( set datatable(i) where i is the loop counter).

the code should look something like this

NoOfRows = No of rows in the table(this can be done dynamically if the table changes all the time)

Code:
For i = 0 to NoOfRows
     Fetch the Record No i
     Save it in the datatable
     Set Datatable(i+1)
Next
Reply
#3
Solved: 11 Years, 4 Months ago
Dear Siri,

Please Read the following post.

https://www.learnqtp.com/forums/Thread-DatabaseExample

I am sure it helps.
Reply
#4
Solved: 11 Years, 4 Months ago
Hi,
The example that you suggested is of MS Access but i need it for oracle database .

Database is devtest
Reply
#5
Solved: 11 Years, 4 Months ago
Hi All,
One more query regarding database .
Can i record the whole sscenerio of the database connection and use for loop so that ican fetch the values to the data table from the database .
Reply
#6
Solved: 11 Years, 4 Months ago
Dear Siri,
The example is of MSaccess but the procedure is same for all the databases.Only the difference is just create a DSN for Oracle Database.
The example i given is retrieves the data from database and writing to the datatable.

So please read the post carefully.

Thanks
Reply
#7
Solved: 11 Years, 4 Months ago
Dear Siri,
Can you post your script here .
I can not not find any attachment with your post.

Thanks
Reply
#8
Solved: 11 Years, 4 Months ago
Hi Im not able to attach any script here or any folder .If you can give me ur email id i can send
Reply
#9
Solved: 11 Years, 4 Months ago
Code:
Set Conn = CreateObject("ADODB.Connection")
Set Rs = CreateObject("ADODB.recordset")

Conn.Open("DSN=devtest ,username=xxx,password=yyy")
sql = "Select Code, Meaning From TB_AMS052_Codes Where Code_Nam = Pole"
Rs.CursorType = 1 'set to a Keyset cursor type’

Rs.Open sql,Conn
Recordcount = Rs.RecordCount

DataTable.GlobalSheet.AddParameter "Meaning",""
While(NOT Rs.EOF)
'Msgbox Rs.Fields("Meaning")
For i=1 to Recordcount
DataTable.SetCurrentRow(i)
DataTable("Meaning",DtGlobalSheet) = Rs.Fields("Meaning")
Rs.MoveNext
Next

wend
DataTable.Export "C:\DatabaseExample.xls"
Conn.close
Set Conn = Nothing
Set Rs = Nothing

This is the script an error saying that the not able to connect to database .Can you tell me the format for connect string for oracle
I need the sequence for the connstrng
Reply
#10
Solved: 11 Years, 4 Months ago
Hi,
My email id is somisays@yahoo.co.uk
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Action Parameterization Issue Slothman 1 1,970 10-31-2020, 01:05 PM
Last Post: Ankur
  Business Components Parameterization YogeshCallappa 0 1,630 06-07-2017, 04:32 PM
Last Post: YogeshCallappa
  Parameterization Hanskanika 0 1,650 11-20-2015, 04:45 PM
Last Post: Hanskanika
  QTP database seach siitohan 1 2,564 02-19-2013, 07:07 AM
Last Post: basanth27
  QTP 11.5 PARAMETERIZATION ERROR QTP(UFT)11.50 mseroney88 2 3,652 01-22-2013, 10:51 AM
Last Post: mseroney88

Forum Jump:


Users browsing this thread: 36 Guest(s)