Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want my database to be in application folder so that it becomes portable i.e it could run on any computer without restoring the database to all computer. is it possible with SQL database if so what would be the code to connect to it.

suppose i have a simple application that uses a database . and i want to run it on another computer then what should i do....

i mean it to run from removable disk ( pen drive )

complete this statement :

sqlconnection con= new sqlconnection ("
Posted

You can use attached database.

You can add SQL Database into your project.

And in the configuration file put the the connection string as

Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

Reference: http://www.connectionstrings.com/sql-server-2005[^]
 
Share this answer
 
v2
Comments
Firo Atrum Ventus 6-Jul-11 1:18am    
Sorry, looks like you missed the point of the question. He want a portable database, your article is about attaching a database into a sql server (which requires installation)
[no name] 6-Jul-11 1:33am    
oops......
 
Share this answer
 
v2

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