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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:09:40+00:00 2026-06-16T07:09:40+00:00

I have an application in C#2010, a database in SQL Server 2008 R2 Express,

  • 0

I have an application in C#2010, a database in SQL Server 2008 R2 Express, I don’t have any problem to connect to my database MyDB on my work PC where I developed the application. But when I tried to install it on an other PC, and after configure my sever like this :

USE [master] 
GO 

CREATE LOGIN [User1] WITH PASSWORD=N'Pass', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=ON 
GO 

EXEC master..sp_addsrvrolemember @loginame = N'User1', @rolename = N'sysadmin' 
GO 

EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 2 
GO

RESTORE DATABASE [MyDB] FROM DISK = N'pathtoMyDB\MyDB.bak' WITH FILE = 1,
NOUNLOAD, STATS = 10 
GO

I run the application, here my problem : when I try to connect to MyDB, I get this message :

Login failed for user ‘WIN-ELKPAS5MS2O\User1’. Reason: Failed to open
the explicitly specified database. [CLIENT: ]

  • 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-16T07:09:41+00:00Added an answer on June 16, 2026 at 7:09 am

    You’ve created a login – that’s fine, but that’s on the server (instance) level. The login gives this account/user rights to connect to the server – that’s just step 1, though.

    Now you’re restoring a database – but you’re not creating a user inside that database that corresponds to that login you’ve just created.

    So after the RESTORE DATABASE, you also need:

    USE MyDB
    GO
    
    CREATE USER User1 FOR LOGIN User1;
    GO 
    

    Now you have a user inside your freshly restored database that corresponds to that login – and now, hopefully, your application will work.

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

Sidebar

Related Questions

I have developed an application using C# on Visual Studio 2010 and SQL Server
I have an access 2010 application with a SQL Server database. But I need
We have an application written in Delphi 2010 which connects to SQL Server Database.
I have a SQL Server 2008 database with a table that contains a FILESTREAM
VS2010 C# SQL Server 2008 Express I developed a couple of apps using Entity
I have already finished a desktop application using Visual Studio 2010 and SQL Server
I developed a desktop application with c# 2010, I have a local .sdf (SQL
I'm trying to connect to an SQL Server 2008 database in a shared hosting
I have some access applications that connect to a SQL Server database. The applications
I have upgraded our TFS 2010 (Win 2008 R2 SP1, SQL Server 2008 R2

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.