Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


VB.net SQLConnect Connection String

Posted on 2009-02-13
Medium Priority
Last Modified: 2012-05-06
I am trying to open a database connection with SQLConnect. Working in Visual studio, when I use the following connection string I get an error message "Login failed for user '**\******'."

Connection string:
"Data Source=*****;Initial Catalog=*******; User ID=**\*****; Password=******; Integrated Security=False;Trusted_Connection=False;"

However, if I use the "Run As" option to run visual studio as the user with access to the database, and use the following connection string it works.

Connection String:
 "Data Source=*******;Initial Catalog=*******; Integrated Security=True"

Why can I not pass the credentials necessary in the connection string to access the database?

(note: all sensitive information is starred out)
Question by:Un-Obtainium
LVL 39

Expert Comment

ID: 23633369
you can only specify SQL login credentials in the userid/password syntax.  You cannot pass windows authentication.  Your Integrated Security=True connection is valid, but if you are running on vista then you must "run as" administrator in order to elevate your account to TRUE admin privileges.
LVL 12

Accepted Solution

Dimitris earned 1000 total points
ID: 23633382
Then you use Integrated Security=True the SQL logins with your windows credentials.
When you use Integrated Security=False you have to login with SQL Login not windows integrated authentication
LVL 27

Expert Comment

ID: 23633397
The credentials are different in the two cases. The first needs a userid and password defined in SQL Server the second uses the current user's Windows logon. So are you using the correct username/password combination in the first example?
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

LVL 64

Expert Comment

by:Fernando Soto
ID: 23633417
Hi Un-Obtainium;

I believe that the, User ID=**\***** with  Password=******;, must be entered into SQL server as a SQL server user with permissions to use the database. I am not an expert on SQL server but believe this to be the issue.

LVL 39

Assisted Solution

BrandonGalderisi earned 1000 total points
ID: 23633509
You can explicitly add a windows account to sql server.  But doing so does not allow you to specify it in the connectionstring.  Use of userid\password is only valid for passing SQL credentials.  For windows authentication, it uses the current user context.  In order to connect with admin privileges under vista with UAC enabled, you have to "Run As" as mentioned.

Author Comment

ID: 23633855
Thanks, I am getting the SQL account created now and I will let you know if it works.
LVL 39

Expert Comment

ID: 23634022
FYI... SQL accounts are not "domain\user".  user accounts containing a \ are interpreted as windows login accounts in the domain\user or computer\user format.

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question