Solved

embeding a databse inside my application

Posted on 2009-07-07
5
306 Views
Last Modified: 2013-11-25
hi

for demo purposes i might need a sql or access database to be embedded inside my application and installed with it and the application will connect to it no matter what the installation path was how to do that ?
0
Comment
Question by:Pure_Heart
  • 2
5 Comments
 
LVL 2

Expert Comment

by:lppperes
ID: 24799927
Hi,
Using a access database, you can install the mdb file in the same path as your exe file.
In your application, connect to your database using a relative path (only the database name) like this:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=My_DB.mdb;Persist Security Info=False"
0
 
LVL 12

Expert Comment

by:funwithdotnet
ID: 24800323
SQL Server Compact 3.5 may be a good option. It is installed in VS 2008 and can even be used to demo web apps.

Another option is to use an XML file. DataSets can be converted to XML with the .WriteXml method. use .WriteXmlSchema to store keys, relationships, etc. After executiing a .ReadXml, a DataSet is ready to go!
0
 
LVL 27

Expert Comment

by:VBRocks
ID: 24803640
You can actually embed the access database into your executable, then when the executable is run, "extract" the database from the executable, write it out to the user's application data directory, then hook up to it from there.

0
 
LVL 27

Accepted Solution

by:
VBRocks earned 250 total points
ID: 24803978
Here's a VS 2005 Demo I put together for you:

    https://filedb.experts-exchange.com/incoming/ee-stuff/7684-ExtractDbDemo.zip


Only things to point out is to add the database to the project:

    Project menu | Add Existing Item...  (navigate to, and select your database)
    In Solution Explorer, right-click on the database, set:
        Build Action = Embeded Resource
        Copy To Output Directory = Do Not Copy

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now