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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:22:27+00:00 2026-06-05T05:22:27+00:00

I am accessing a service based database by using the following connection string static

  • 0

I am accessing a service based database by using the following connection string

static string appath = Library_Records.Program.app_path;

string connectionstring = @"Data Source=.\SQLEXPRESS;AttachDbFilename=appath;Integrated Security = true;User Instance = True";
connection = new SqlConnection(connectionstring);

 static string dbfiles = null;
 internal static string app_path
 {
     get { return dbfiles = "|Datadirectory|\\5700.mdf"; }
 }

Library_Records:namespace, Program is the class name containing Main()

When I call connection.Open(), it gives the following error

An attempt to attach an auto-named database for file appath failed. A
database with the same name exists, or specified file cannot be
opened, or it is located on UNC share.

5700 is my database with .mdf extension. How to rectify this problem?

  • 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-05T05:22:28+00:00Added an answer on June 5, 2026 at 5:22 am

    Variables are never automatically replaced with values in strings, so AttachDbFilename=appath; will not work.

    You should do something like:

    string connectionstring = 
        string.Format(@"Data Source=.\SQLEXPRESS;AttachDbFilename={0};Integrated Security=True;User Instance=True", appath);
    
    connection = new SqlConnection(connectionstring);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a java-based tool that includes jaxws-rt-2.1.4.jar for accessing web services. I
This relates to my other question on accessing a REST service that uses forms
I am getting an error while accessing the core service on SDL Tridion 2011
I have a asp.net website and I am accessing that web service from my
I am accessing an existing WCF web service (which returns a PDF as a
I have a Windows Service which is basically accessing a mailbox and reading the
I am getting this exception while accessing the jax-ws web service from my client.
I am currently accessing a web service. The only message I got from the
Is it possible to use Simperium (http://simperium.com) with a document based Core Data app?
I have a WCF service hosted on a server. A client application is accessing

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.