?
Solved

embeding a databse inside my application

Posted on 2009-07-07
5
Medium Priority
?
339 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 1000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

741 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