Click here to Skip to main content
16,004,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here i have done a c# program and it reads some information from the database
but and i already set the database path in the program but what the problem is when i build it to an exe file we have to keep the path of database the same
so i think can i add databse with in the solution .so can any one give me the sample code.the database used is of ms sqlserver 2008
Posted

You don't need the path: the connection string is all you need to get to the database. See here[^] for a large variety of connection strings you can use (and adapt).
 
Share this answer
 
Change your connectionString with the following and substitute "Library" database name with your database name:

string constr;
constr = "Data Source=.\\SQLEXPRESS;database=Library;Persist Security Info=False;Integrated Security=True;";
 
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