Embed a local Access database into a Windows Application (VB .Net)

I'm creating a standalone windows application which will create and store invoices. It will use an embedded, local MS Access db as the datastore.

I have included the db in the VB .Net project and created the connection string to it. The path is:

C:Documents and Settingsdigbd0My DocumentsVisual Studio 2005ProjectsInvoiceGeneratorTimeExpenses.mdb

When I build the project it outputs everything to the bin folder:

C:Documents and Settingsdigbd0My DocumentsVisual Studio 2005ProjectsInvoiceGeneratorinTimeExpenses.mdb

This is then a different path to the database so any inserts, updates etc take place on this copy of the db.

When I want to distribute the solution to a user (it is only a single user application so the db is not shared) how should I code the connection string so the path is not hardcoded as above and points to the location in which the database is installed?


Comments

  • [b][red]This message was edited by dokken2 at 2006-9-5 12:5:13[/red][/b][hr]
    : I'm creating a standalone windows application which will create and store invoices. It will use an embedded, local MS Access db as the datastore.
    :
    : I have included the db in the VB .Net project and created the connection string to it. The path is:
    :
    : C:Documents and Settingsdigbd0My DocumentsVisual Studio 2005ProjectsInvoiceGeneratorTimeExpenses.mdb
    :
    : When I build the project it outputs everything to the bin folder:
    :
    : C:Documents and Settingsdigbd0My DocumentsVisual Studio 2005ProjectsInvoiceGeneratorinTimeExpenses.mdb
    :
    : This is then a different path to the database so any inserts, updates etc take place on this copy of the db.
    :
    : When I want to distribute the solution to a user (it is only a single user application so the db is not shared) how should I code the connection string so the path is not hardcoded as above and points to the location in which the database is installed?
    :
    :
    :

    VB6 has an App object with a Path property, in .Net use -

    MessageBox.Show(System.Reflection.Assembly.GetExecutingAssembly.Location)

    from the Location property, you can derive the path and pass that to the connection string
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion