Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DB connection string issue
#1
Solved: 11 Years, 4 Months, 3 Weeks ago Question 
I’ve been trying to figure out how to write the connection string (for a database which uses named instance) in QTP test scripts without success.

In a different computer where default named instance is used then the following works
Code:
cnt.ConnectionString= "Driver={SQL Server};Integrated Security=SSPI;Initial Catalog=cccccc;[b]Data Source=.[/b];UID=uuuuuu;PWD=pppppp;Trusted_connection=True"

but in a computer where instance name is used, I tried the followings:

Code:
cnt.ConnectionString= "Driver={SQL Server};Integrated Security=SSPI;Initial Catalog=cccccc;[b]Data Source=.\instance_name[/b];UID=uuuuuu;PWD=pppppp;Trusted_connection=True"
cnt.ConnectionString= "Driver={SQL Server};Integrated Security=SSPI;Initial Catalog=cccccc;[b]Data Source=computer_name\instance_name[/b];UID=uuuuuu;PWD=pppppp;Trusted_connection=True"
cnt.ConnectionString= "Driver={SQL Server};Integrated Security=SSPI;Initial Catalog=cccccc;[b]Data Source=computer_ipaddr\instance_name[/b];UID=uuuuuu;PWD=pppppp;Trusted_connection=True"
but nothing works!!!

I’m wondering if anyone here can show me how to; I’d really appreciate your help.
Thanks in advance.
Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
This is what I use and it works for me:

Code:
objDB.ConnectionString = "Provider=SQLOLEDB; Data Source=MACHINENAME\INSTANCENAME; Initial Catalog=DATABASENAME; Integrated Security=SSPI; Trusted_Connection=Yes"
objDB.Open

This assumes Windows Authentication so you do not need the username and password. If you need SQL authentication then you need to drop the Integrated Security=SSPI; Trusted_Connection=Yes" and put in your username and password.
Reply
#3
Solved: 11 Years, 4 Months, 3 Weeks ago
Please ensure to include your code between [code] tags while asking or replying to questions. I have done this for you for this time.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Connection to oracle using JDBC and QTP dileep45 0 3,469 07-30-2013, 06:39 PM
Last Post: dileep45
  Connection string for oracle (Remote DB) in QTP rohit330 1 6,121 02-23-2012, 07:53 PM
Last Post: rohit330
  How to have a variable that has a string comma string .. shareq1310 5 5,098 11-09-2011, 03:33 PM
Last Post: parminderdhiman84
  Database connection - TNS error Shwetha 2 5,055 05-24-2011, 02:27 PM
Last Post: surya_7mar
  Remote Database connection through QTP PrabhatN 4 8,022 12-02-2010, 12:53 PM
Last Post: cdesserich

Forum Jump:


Users browsing this thread: 1 Guest(s)