Click here to Skip to main content
15,124,487 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi All,

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.

complete this statement :

sqlconnection con= new sqlconnection ("
Posted
Updated 24-May-17 5:29am
v2

If you use SQL Server, you will be setting up the DB on a server.
As a result, it will be accessible to all users who have privileges to access the DB (and machine)

Moving the DB around is not recommended as your db is expected to grow and become less and less portable.

For a connection string, try http://www.connectionstrings.com/[^].
   
Comments
fjdiewornncalwe 5-Jul-11 8:13am
   
You've covered it all. +5.
Abhinav S 5-Jul-11 8:13am
   
Thank you.
Member 8043849 5-Jul-11 8:24am
   
no its not covered .. plz help


suppose i have a simple application that uses a database . and i want to run it on another computer then what should i do....
Member 8043849 5-Jul-11 8:24am
   
no its not covered .. plz help


suppose i have a simple application that uses a database . and i want to run it on another computer then what should i do....
If you want a portable application, you must use a "portable" database.
There are more solutions to do it, for example: SqLite, Sql Server Compact Edition, Xml ,etc.

Remember:
If you want to use a RDBMS, you must install the correct database engine and make sure that the DB dll are copied in the output folder, otherwise if you choose a xml database you do not need a db engine.
   
v3
The problem is Windows. Vista and Windows 7 do not allow you to put data files into any subfolder inside the Program Files folder. It forces you to use the "special" user data folders. This is a security issue. You can, however, create a script that you can run on the database server that will create all of the tables, stored procedures, functions, triggers, and views when your app is installed.
   
Comments
cicciocrazy 5-Jul-11 8:55am
   
That is for a traditional installation. But if the program must be Portable, i suppose that It run from an external disk.
So there are no problems.
Member 8043849 5-Jul-11 9:06am
   
ya u r right i mean it to run from removable disk ( pen drive )

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