1

I am creating a database based application. I have created a solution which contains 2 projects

1) Windows forms application

2) Datalayer - where i have added a sql server database to a folder.

I know that its something related to path but i am not able to figure it out.

enter image description here

This is the app.config of datalayer

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="BillingKioskDatalayer.Properties.Settings.BillingDBConnectionString"
            connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\DB\BillingDB.mdf;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
</configuration>

I added 'User Instance=True' ran the solution again and got the same exception.

"An attempt to attach an auto-named database for file E:\XGHProjects\BillingKiosk\BillingKiosk\bin\Debug\DB\BillingDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."

Below is the property window of the db file.

enter image description here

Initially it was getting copied in the billingkiosk's debug folder but then i updated "Copy to output directory property to Do Not Copy. I have been through following links :

http://forums.asp.net/t/956274.aspx

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/6dfdcc22-7a81-4e8f-a947-c1ce6982d4b3/flustered-a-database-with-the-same-name-exists-or-specified-file-cannot-be-opened-or-it-is?forum=sqlexpress

"An attempt to attach an auto-named database" error

An attempt to attach an auto-named database for file **** failed

An Attempt to attach an auto-named database Error

Do i need to change the structure of the solution ?

Community
  • 1
  • 1
Hemant Bavle
  • 3,297
  • 1
  • 24
  • 30
  • Once I Face The same Problem But unfortunately I dont remember the solution.But IMHO You dont need to change the Structure it will solve with some trick. – Umar Abbas Jun 21 '14 at 07:57
  • Have you found the solution? Can't believe there are no answers posted below. I am facing the same problem and got here via Google Search results. Hope someone can post any solution to this problem. – YourFriend Apr 18 '15 at 10:37

0 Answers0