Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How do i add an App_Data in my window application. Actaully i am facing an issue like

An attempt to attach an auto-named database for file c:\inetpub\wwwroot\Demo\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

For this error i got an article saying that keep .mdf file in App_Data folder if we give path as AttachDbFilename = | DataDirectory | / Database.mdf; (as of now i am giving same path) in connection string. so i need an App_Data folder in window application if not how to solve this error.

my connection string as fallows:

<add name="BCT">
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SQL2005_652242_bct_data.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
Posted

1 solution

1.You could add and/or create any folder in your windows application, by using "Solution Explorer".

2.Regarding your database file, after you add the folder that contains the database in a subfolder of your windows application, you have to change the AttachDbFilename in your connection string, to point to the .MDF file from your new folder.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900