Click here to Skip to main content
15,894,630 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am getting an error as 'unable to attach auto named database for file: " d:\new folder\a.mdf"'.
this error occurs when i run my project setup on other PC.Is there any solution to create a dynamic conectionString so that when i give my setup to anyone it should be error free?
also I am getting error as cannot open database "sample.mdf" requested by login.the login failed.

please help me as soon as possible..
Posted
Updated 12-Mar-13 20:41pm
v2

u can use application Start up path. meant use path when your application is installed.


Happy Coding :)
 
Share this answer
 
Comments
Dev Gupta from Mumbai,India 13-Mar-13 2:49am    
Can you explain in detail? I am new to C# winforms..
Member 9444634 13-Mar-13 5:28am    
i read your Solution 2 comments, i think u need some basic knowledge without knowing it u can't do this type of programming.
C#
string DPath=Application.StartupPath + "\\xyz.mdb"

string ConString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + DPath ;

OleDbConnection cnn = new OleDbConnection(ConString);


Hope this will help you.... :)
 
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