Deploying VS 2003 Application w/Access Database

P

pooba53

I have a VB .NET 2003 application that communicates with an Access db.
I am deploying the application using the Wizard that creates an install
package and it IS properly grabbing the Access db and putting it in the
Program Files directory along with the application executable, no
problem.

The problem is this...

The OleDbConnection knows of the database in an absolute location (i.e.
C:\Documents and Settings\ApplicationDB\data.mdb

So whenever I install and launch the application on another machine, it
looks for the database at the location I just mentioned. Well, I have
the database in the same directory as the application .exe file.

I need to be able to use a reference to the database based on relative
position I guess rather than absolute location.

Anybody know how to configure this?

Thanks...this group has been very helpful.
-Dan
 
P

pvdg42

pooba53 said:
I have a VB .NET 2003 application that communicates with an Access db.
I am deploying the application using the Wizard that creates an install
package and it IS properly grabbing the Access db and putting it in the
Program Files directory along with the application executable, no
problem.

The problem is this...

The OleDbConnection knows of the database in an absolute location (i.e.
C:\Documents and Settings\ApplicationDB\data.mdb

So whenever I install and launch the application on another machine, it
looks for the database at the location I just mentioned. Well, I have
the database in the same directory as the application .exe file.

I need to be able to use a reference to the database based on relative
position I guess rather than absolute location.

Anybody know how to configure this?

Thanks...this group has been very helpful.
-Dan
One way to address you problem is use of a relative path instead of the
absolute path.
You can Google (groups) up numerous articles on relative path, but here's a
quote that may be of interest:

If the database path is relative to the location of your application
(executable) path then use the
following:


Dim DatabasePath As String


Dim FileInfoPath = New
System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly.Location­)


DatabasePath = FileInfoPath.Directory.FullName & "\Database"
 
A

Armin Zingler

pooba53 said:
I have a VB .NET 2003 application that communicates with an Access
db. I am deploying the application using the Wizard that creates an
install package and it IS properly grabbing the Access db and
putting it in the Program Files directory along with the application
executable, no problem.

The problem is this...

The OleDbConnection knows of the database in an absolute location
(i.e. C:\Documents and Settings\ApplicationDB\data.mdb

So whenever I install and launch the application on another machine,
it looks for the database at the location I just mentioned. Well, I
have the database in the same directory as the application .exe
file.

I need to be able to use a reference to the database based on
relative position I guess rather than absolute location.

Anybody know how to configure this?

Thanks...this group has been very helpful.
-Dan


OleDB still needs the absolute position, but if you are looking for the
application's exe file, you find it at
System.Windows.Forms.Application.ExecutablePath

Use IO.Path.GetDirectory to extract the directory and IO.Path.Combine to
combine the directory name and the database name to build the full path used
to open the database.


Armin
 
P

pooba53

Perhaps I'm not explaining correctly:

Within the connection string to my Access database there is a line that
looks like this:

Data Source=""C:\Documents and Settings\usrdel\My Documents\Visual " &
_
"Studio Projects\Debt Accelerator\data.mdb""

So when I build my project for deployment and install it on another
computer, it looks for the Access database at the above location
instead of the directory where my VB executable and the Access database
is located.

Is there a way to make this connection string relative instead of
absolute? How are folks deploying their applications that include a
database? Seems like one should be able to move the application
directory containing the executable and the database wherever the hell
you want and still work.

Can I provide any more information?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top