Micro Focus QTP (UFT) Forums

Full Version: QTP Database conenction and parameterization of the values
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
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 .
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
Dear Siri,

Please Read the following post.

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

I am sure it helps.
Hi,
The example that you suggested is of MS Access but i need it for oracle database .

Database is devtest
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 .
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
Dear Siri,
Can you post your script here .
I can not not find any attachment with your post.

Thanks
Hi Im not able to attach any script here or any folder .If you can give me ur email id i can send
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
Hi,
My email id is somisays@yahoo.co.uk
Pages: 1 2 3 4 5