How do I connect to database (Access in my case) from QTP?

Questions by ilts

Showing Answers 1 - 2 of 2 Answers

vijaykumar

  • Apr 10th, 2006
 

yes u can connect through DSN.( create DSN from control panel).And create bd copnnective object like, set dbconnect= createobject("ADODB>connection"). and checkdbcfonnection.open is true or not.

  Was this answer useful?  Yes

The below code...will connect to database


Set xlconn=createobject("ADODB.connection")
Set xlrset=createobject("ADODB.recordset")
connstring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Documents and SettingsmavDesktopseshudb1.mdb;User Id=admin;Password=;"
xlconn.open connstring
sql="select name from customer_table"
xlrset.open sql , xlconn,3,3
' Resultant value..is stored in the variable Result

Result=xlrset.fields(0).value
xlconn.close


   just change the connection string....when u are trying to access different database.....as the above code is to connect to Microsoft Access database..

if u want to know the connection string for different databases  u can log on to ...

www.connectionstrings.com

hope this information ....helps u ..in connecting to the different databases....

if u still have any queries..plz....give me reply

  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