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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:59:30+00:00 2026-06-06T11:59:30+00:00

Apparently, using AttachDbFilename and user instance in your connection string is a bad way

  • 0

Apparently, using AttachDbFilename and user instance in your connection string is a bad way to connect to a DB. I’m using SQL server express on my local machine and it all seems to work fine. But what’s the proper way to connect to SQL server then?

Thanks for your explanation.

  • 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-06T11:59:32+00:00Added an answer on June 6, 2026 at 11:59 am

    Using User Instance means that SQL Server is creating a special copy of that database file for use by your program. If you have two different programs using that same connection string, they get two entirely different copies of the database. This leads to a lot of confusion, as people will test updating data with their program, then connect to a different copy of their database in Management Studio, and complain that their update isn’t working. This sends them through a flawed series of wild goose chase steps trying to troubleshoot the wrong problem.

    This article goes into more depth about how to use this feature, but heed the very first note: the User Instance feature has been deprecated. In SQL Server 2012, the preferred alternatives are (in this order, IMHO):

    1. Create or attach your database to a real instance of SQL Server. Your connection string will then just need to specify the instance name, the database name, and credentials. There will be no mixup as Management Studio, Visual Studio and your program(s) will all be connecting to a single copy of the database.

    2. Use a container for local development. Here’s a great starter video by Anna Hoffman and Anthony Nocentino, and I have some other resources here, here, and here. If you’re on an M1 Mac, you won’t be able to use a full-blown SQL Server instance, but you can use Azure SQL Edge if you can get by with most SQL Server functionality (the omissions are enumerated here).

    3. Use SqlLocalDb for local development. I believe I pointed you to this article yesterday: "Getting Started with SQL Server 2012 Express LocalDB."

    4. Use SQL Server Compact. I like this option the least because the functionality and syntax is not the same – so it’s not necessarily going to provide you with all the functionality you’re ultimately going to want to deploy. Compact Edition is also deprecated, so there’s that.

    Of course if you are using a version < SQL Server 2012, SqlLocalDb is not an option – so you should be creating a real database and using that consistently. I only mention the Compact option for completeness – I think that can be almost as bad an idea as using AttachDbFileName.

    EDIT: I’ve blogged about this here:

    • Bad Habits : Using AttachDBFileName
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok I am using Flotr2 to make a graph, and apparently the only way
You can't have your cake and eat it too, apparently. I'm currently using the
I'm using the Mirth Connect listener and so can receive HL7 XML fine (apparently).
I have an application using in-app purchase. Apparently, if the user has a jailbroken
Apparently, there are two ways to obtain a thread-safe HashSet instance using Java’s Collections
I'm looking for an example of using OpenSSL's AES CCM encryption. Apparently, this is
I was trying to make my own class for currencies using longs, but apparently
Edit: derp, using pageX/Y instead of clientX/Y -- apparently scrollBy expects input with that
Sorry, this is my first time using this forum. Apparently people can edit my
I have a database on line with Godaddy (who uses SQL Server 2005). They

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.