CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: SQL connection

  1. #1
    Join Date
    Sep 2005
    Location
    Cracow, Poland
    Posts
    345

    Question SQL connection

    I try to connect to database Northwind and I get an error while using the Open() method: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

    What does it mean?

  2. #2
    Join Date
    Jun 2005
    Posts
    121

    Re: SQL connection

    Hello,
    I think your sql server is set up so that it only accepts Windows Authentication. You will have to change the LoginMode key under HKEY_LOCAL_MACHINE\Software\Microsoft\MSSqlserver\MSSqlServer to a value of 2. Before doing that stop al MSSqlServer services. After changing it restart MSsqlServer.

  3. #3
    Join Date
    Sep 2005
    Location
    Cracow, Poland
    Posts
    345

    Re: SQL connection

    Yes, you guessed right. I changed that value to 2. Now I get such error (in the same place): Login failed for user 'sa'.

  4. #4
    Join Date
    Jun 2005
    Posts
    121

    Re: SQL connection

    Hi again,
    "The default authentication mode for MSDE is Windows Authentication. MSDE installs with a built-in system administrator (SA) user account. However, because SQL Server Authentication is disabled by default, you cannot access the built-in account after a typical installation." this is from http://support.microsoft.com/default...b;en-us;319930. Follow the steps in "Connect to MSDE with SQL Server Authentication" paragraph.
    Here is another article that you might find helpful :http://support.microsoft.com/default...b;en-us;322336

  5. #5
    Join Date
    Sep 2005
    Location
    Cracow, Poland
    Posts
    345

    Re: SQL connection

    Actually it was enough to pass a connection string, that didn`t include a password.

    Nevertheless, thanks for your effort

  6. #6
    Join Date
    Feb 2006
    Posts
    3

    Thumbs up Re: SQL connection

    Just Go in SQL SERVER Enterprise Manager. under the logins
    Set User Name = sa
    and password= sa
    then try again. .

  7. #7
    Join Date
    Sep 2005
    Location
    Cracow, Poland
    Posts
    345

    Question Re: SQL connection

    I have created my own database,
    I set the appriopriate key value (from previous posts) to 2,
    I created a user "martinez", that have all possible rights,
    and I`m still getting such error:


    Code:
    "Login failed for user 'martinez'. The user is not associated with a trusted SQL Server connection."
    Someone can help me?

    thank you in advance

  8. #8
    Join Date
    Apr 2005
    Posts
    102

    Re: SQL connection

    Is the sql server setup to use both windows and sql authentication?

    how to check:
    Open The SQL Server Enterprise Manager
    Start menu > Programs > Microsoft SQL Server > Enterprise Manager)
    Expand the tree-control until you can see your server
    Right click on the server name and "SQL Server Properties (Configure)" window will open
    Select the Security tab
    For "Authentication", select "SQL Server and Windows"

  9. #9
    Join Date
    Sep 2005
    Location
    Cracow, Poland
    Posts
    345

    Re: SQL connection

    Yes, I think that that was a reason, thank you for help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured