Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I create a image store application for store image in db. its work on correctly.
How to attach db with exe for use on any computer??

What I have tried:

how to attach db with exe for any use on any computer?
Posted
Updated 28-Feb-16 22:52pm

You can ship the MDF file along with application executable. Your set up project should check for SQLExpress and if not present should install it. Then, it should also copy the MDF file at desired location. The connection string should be like this:
C#
Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;Database=dbname;
Trusted_Connection=Yes;
 
Share this answer
 
Comments
Arslan saif 29-Feb-16 4:47am    
sorry but I cant understand what you say
dan!sh 29-Feb-16 4:49am    
Which part? Your set up should include: application executable, MDF file for database, SQLExpress setup. Your connection string in code should be like one above.
What db are you using? If you are using SQL CE db / or mdb then you can deploy with your executable directly, alternatively you may choose to create installer and deploy the database along with the executable in the installer directory.
If you are using mdf then you need to be sure that the client has sql server installed else you need to include the sqlserver installer along with your application installer.
 
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