Click here to Skip to main content
16,018,347 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
I attached a database using connection string
"
data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\Data\ABC.mdf;User Instance=true;Initial Catalog=ABC<code><small></small></code>;Connect Timeout=30;
"
this works well
I changed my project location ,Its not working with the new location.
Can not attach Database already exist exception is comming
please help me to solve the problem

What I have tried:

data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\Data\ABC.mdf;User Instance=true;Initial Catalog=ABC;Connect Timeout=30;
Posted
Updated 28-Jan-18 21:07pm
Comments
VR Karthikeyan 29-Jan-18 0:38am    
delete the existing connection and retry.

1 solution

Do not attach databases, except in dev - it's a special mode for dev only that does not exist in the full version of SQL (for very good reasons). You should ensure that production DB's are managed and controlled by SQL, which means it will store it where it wants.

You can also use this: Simple SQL Connection String Creation[^] to generate a connection string for you.
 
Share this answer
 
Comments
Member 10296413 29-Jan-18 22:10pm    
Im using Wpf ihave to create exe
OriginalGriff 30-Jan-18 5:47am    
What does that have to do with anything? In order to run any app under Windows you need to generate an EXE file...

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