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 8901733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:26:04+00:00 2026-06-15T01:26:04+00:00

I am trying to establish a connection to a Microsoft Sql Server express edition

  • 0

I am trying to establish a connection to a Microsoft Sql Server express edition databse called PrimeMinisters and get the following error.

Cannot open database "PrimeMinisters" requested by the login. The login failed. Login failed for user 'DESKTOP\Arian'. 

I am asuming I need a user name and password but as this is just for home use I dont see the need for a username and password in the connection string.

I added the database as a new connection in database explorer and this is the connection string I added to the eventhandler.(desktop is the name of my pc)

 try
    {
        string connect = @"Data Source=DESKTOP\SQLEXPRESS; Initial Catalog=PrimeMinisters; Trusted_Connection=Yes;"; 



        SqlConnection sqlConn = new SqlConnection(connect);
        sqlConn.Open();

        LabMessage.Text = "A connection has been established";
    }
    catch (Exception ex)
    {
        LabMessage.Text = ex.Message.ToString();
    }

How can I overcome this error message and establish a connection with the database?

Kind regards

  • 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-15T01:26:06+00:00Added an answer on June 15, 2026 at 1:26 am

    Your application is correctly establishing communication to SQL Server but the server does not authorize your current user (DESKTOP\Arian) to connect. You need to enter authentication information for account which is allowed to use SQL Server.

    SQL Server allows two modes of authentication:

    1. Windows authentication

    where authorization is performed against Windows account under which connecting application is running. In your case, your application is running under DESKTOP\Arian. To use this you should add Integrated Security=SSPI to your connection string.

    1. SQL Server authentication

    where accounts are created just for the SQL Server instance. This can be done during setup or later by issuing appropriate commands with user that has sufficient privileges. To use this type of authentication set integrated security to false (Integrated Security=false) and set valid user name and password (User Id=Arian;Password=secretsquirrel)

    If you have forgotten all passwords you can take a look at this answer for instructions on how to reset a password.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to establish a connection to a server that sends 401 Authentication Error
We're getting the following error when trying to establish a connection to a database
I'm trying to establish a second database connection to another database on another server.
HI folks, I'm trying to establish connection to a remote server using ruby socket
I've been trying to replicate the unable to establish connection error in one of
I am trying to establish connection between ZABBIX SERVER which has been installed on
I am trying to establish a connection between my mail server and a java
I am trying to establish a connection between Android Client and C# Server ..
I have the following code that's trying to establish a connection to a remote
I'm trying to establish and udp connection between a server and an android device.

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.