Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7929463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:05:07+00:00 2026-06-03T20:05:07+00:00

I am attempting to connect to Microsoft SQL Server 2008 R2 from within Microsoft

  • 0

I am attempting to connect to Microsoft SQL Server 2008 R2 from within Microsoft Visual Studio 2010. My connection string is as follows:

connection = New SqlConnection("Server=localhost;Database=greenapplication;User ID=WindowsID;Password=WindowsPassword")

I keep getting this exception: System.Data.SqlClient.SqlException:

Login failed for user 'WindowsID'.

What am I doing wrong? Are there certain permissions that I have to set up?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:05:08+00:00Added an answer on June 3, 2026 at 8:05 pm

    If you are trying to use integrated security, your connection string should be:

    "Server=localhost;Database=greenapplication;Trusted_Connection=True"
    

    You then manage permissions through roles and windows groups. (You can grant individual users permissions, but this is not the recommended way to manage database access).

    UPDATE: You neglected to mention in original question that this is a web application. The usual way to handle this is to create an app. pool running under a known identity (say NETWORK SERVICE), and then give that identity the necessary permissions on the database.

    • Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication

    Here’s an example:

    -- Create a SQL Server login for the Network Service account
    sp_grantlogin 'NT AUTHORITY\Network Service'
    
    -- Grant the login access to database
    USE MyDB
    GO
    sp_grantdbaccess 'NT AUTHORITY\Network Service', 'Network Service'
    
    -- Add user to read only database role
    USE MyDB
    GO
    sp_addrolemember 'db_datareader', 'Network Service'
    

    If you insist on using the less secure method of passing of username and password in connection string, use SQL Server logon:

    • How To: Connect to SQL Server Using SQL Authentication in ASP.NET 2.0
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to connect to a SQL Server 2008 R2 instance from another
When attempting to connect to a SQL Server 2008 Instance using Management Studio, I
I'm attempting to connect to a SQL Server Compact Edition database from F#, and
I'm attempting to connect to a SQL Server database within a Python script. I'm
I am attempting to connect to SQL Server running on Windows XP system from
I'm attempting to take Excel 2003 and connect it to SQL Server 2000 to
I am attempting to connect to a remote MySQL server from my local machine
I'm attempting to connect to a remote HTTPS SVN server from inside a corporate
I am attempting to connect a new Orbeon XForm to an existing exist db.
I'm attempting to connect to an api and get a user from a donation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.