By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,646 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

Deploying VS 2003 Application w/Access Database

P: n/a
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

Jan 20 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"pooba53" <po*****@gmail.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
>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.GetE xecutingAssembly.Location*)
DatabasePath = FileInfoPath.Directory.FullName & "\Database"

Jan 20 '07 #2

P: n/a
"pooba53" <po*****@gmail.comschrieb
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

Jan 21 '07 #3

P: n/a
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.

pvdg42 wrote:
"pooba53" <po*****@gmail.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
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'sa
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.GetE xecutingAssembly.Location*)
DatabasePath = FileInfoPath.Directory.FullName & "\Database"
Jan 23 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.