Solved SQLConnect Connection String

Posted on 2009-02-13
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

    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

    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

    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?
    LVL 62

    Expert Comment

    by:Fernando Soto
    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

    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.
    LVL 1

    Author Comment

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

    Expert Comment

    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

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    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.
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now