Solved

embeding a databse inside my application

Posted on 2009-07-07
5
333 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
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…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

690 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