Solved

embeding a databse inside my application

Posted on 2009-07-07
5
291 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

11 Experts available now in Live!

Get 1:1 Help Now