I have made a connection to Access database from QTP using ADODB connection,,,, and also declared a recordset for it....There are 2 rows in the database and i want to fetch the values from all the rows...But the problem is that when the first record is fetched , QTP runs the whole script and again starts for the first line of the QTP code for the second iteration....and in this process it again opens the same connection and fetches the same first row again..... Can anyone tell me how to fetch the values from next of database in the next iteration....I shall be thankful if anyone can provide me the code for the same ...tx.

Questions by shibu1

Showing Answers 1 - 3 of 3 Answers

ramkumary

  • Sep 29th, 2006
 

Hai

Let me know if it is wrong

1.Write 3 Fucntions which have different data base connection open and recordser declaration.

Func1()

For Ms access

Func2()

For Oracle

Func3()

For Sql Server

2.Declare 1 variable in the beginning and set value=1 while in the first iteration

After the end the each iteration update the value by1(i.e 2)

3.Write a one more function called Validate

funcValidate()

It should verify the current value if Step 2 varibale

If value of the varible=2

Call func2()

If value of the varible=3

Call func3()

My Mail id : ramyoganathan@aim.com

Warm Regards

Ram.

  Was this answer useful?  Yes

mkgeek7

  • May 29th, 2007
 

After creating a SQL Server 2005 database, I have problem connecting to the database using OBDC from QTP. Please can you post your script for SQL server database connection from QTP.

Thanks
Yared

  Was this answer useful?  Yes

Set Conn = CreateObject("ADODB.Connection" )

str="DRIVER={MySQL ODBC 5.1 Driver};SERVER=localhost;DATABASE=employee;user id=root ; password=stc"

Conn.open str

Set Rs = CreateObject ("ADODB.Recordset" )

Set Rs1 = CreateObject ("ADODB.Recordset" )

sql = "select * from emp;"

sql1="select count(*) from emp;"

Rs.open sql,conn

Rs1.open sql1,conn

c=Rs1(0)

msgbox "no. of rows "&c

For  i= 0 to cint(c)-1

MsgBox Rs(0)&" | "&Rs(1)

Rs.Movenext

next

Rs1.close

Set Rs1 = Nothing

Rs.close

Set Rs = Nothing

Conn.close

Set Conn = Nothing

 

 

tell me is it helpful for u or not

Raghu, stcthirdeye@yahoo.co.in

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions