How to connect to SQL Server 2005 database from QTP

I created my database in SQL Server 2005 and used the following script to connect to my database from QTP. But it didn't work

im ObjDB
Set ObjDB= Create Object("ADODB Connection")

ObjDB.ConnectionString = "DSN=Database Name"
ObjDB.Open


StrQuery = "Select * From Table Name Where Condition for query"
Set ObjResult = ObjDB.Execute(StrQuery)


After I run the script in QTP. I'm getting the following error message

"The test run cannot continue due to a syntax error.

Expected end of statement"

or Detail error message

"Line (3): "Set ObjDB= Create Object("ADODB Connection")"


Thanks
Yared

Showing Answers 1 - 1 of 1 Answers

adisgee

  • Aug 2nd, 2007
 

Instead of creating an MS Access DSN , create a Sql Server DSN using a SQL Server ODBC driver for connectivity.

Hope this helps.

THe syntax in the answer to the above question is accurate.

Thanks,
Aditya.

  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