Search code examples
sqlvbscripthp-uft

connect to a database using vbscript in UFT


I am trying to connect to database using a test account for running my automation

 connStr.open "provider=SQLOLEDB;Server=SEACITMFGCM11.itlab.local;User Id=" & userName & "; Password=******; Database=MfgDb;Trusted_Connection=Yes"

my username and this test account has access to database, so i was able to connect without any issues. But my collegue who doesn't have access to database try to run my automation and this connstr.open is still using windows authentication user to login and failing.

In the watch i saw the connection string as

Provider=SQLOLEDB.1;User ID=OLYMPUS\ITQAAUTOTEST01;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=SEA-L-00020821;Use Encryption for Data=False;Tag with column collation when possible=False;"

I don't see the password in the connection string.

How can i make the code to connect to the database using my test account OLYMPUS\ITQAAUTOTEST01 and not my account

Can someone please help?


Solution

  • "Trusted_Connection=Yes" in your connection string is telling it to use the credentials of the currently logged in user, ignoring the username and password you specified in the connection string. Remove the "Trusted_Connection=Yes".