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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:25:51+00:00 2026-06-06T00:25:51+00:00

I have a database in my local machine. I have a C# application that

  • 0

I have a database in my local machine. I have a C# application that uses LINQ to SQL to insert records into this database. I opened the database (and selected records in a query window) using SSMS ( SQL Server Management Studio). Now, if I try to run the C# application, I am getting the following error :

“Cannot open user default database. Login failed. Login failed for user DFGV\G16570'.”

This error goes away when I restart the system.

Note: I am using Integrated Security=True

Note: The SQL Server is running with “LocalSystem” account

Connection String in LINQ:

 Data Source=.; AttachDbFilename=C:\DevTEST\Databases\LibraryReservationSystem.mdf;
 Integrated Security=True; Connect Timeout=30;User Instance=True

Note: “User Instance” keyword

Following is my LINQ query:

public virtual void InsertOnSubmit(T entity)
    {
        GetTable().InsertOnSubmit(entity);
        Context.SubmitChanges();
    }

What should I do in order to make the LINQ to work when I am connected to the database through SSMS?

EDIT

Based on response, I changed the code as shown below.

   string connectionstring = "Data Source=.;Initial Catalog=LibraryReservationSystem;Integrated Security=True;Connect Timeout=30";

        using (var context = new RepositoryLayer.LibraryManagementClassesDataContext(connectionstring)) 
        {

            RepositoryLayer.Repository<RepositoryLayer.Account> selectedRepository = new RepositoryLayer.Repository<RepositoryLayer.Account>();
            selectedRepository.Context = context;
            AccountBusiness accountBl = new AccountBusiness(selectedRepository);

            //List<RepositoryLayer.Account> accountList = accountBl.GetAllAccounts();
            accountBl.InsertAccounts();
        }

Note: Made sure that “User Instance” keyword is NOT set as TRUE

  • 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-06T00:25:53+00:00Added an answer on June 6, 2026 at 12:25 am

    You are opening the database using the AttachDbFilename option which means the database is opened as a user instance, accessible only by the process identity that opened it.

    If you want to access the database from multiple processes, attach it to a proper SQL Server instance and then connect to it passing the name of the database in the InitialCatalog property. Don’t use AttachDbFileName and UserInstance.

    This is described in Using SQL Server Express with ASP.NET

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

Sidebar

Related Questions

I have a small ruby application that I made on my local machine. It
I have a very simple app on my local machine that uses the ASP.NET
I am developing an android application in which i have a local database.I want
I would like to develop an Android application which will have a local database.
I have a database working in my local sql server 2005 express edition. I
I have an ASP.NET application that does a large database read. It loads up
I have made a MVC application that uses the built-in ASP.NET login functions. It
I have an application that connects to a database and can be used in
I have a distributed windows application (written in C#) that currently uses MSDE. The
I run an in-house application, programmed with visual studio 2008, that uses SQL Server

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.