VB Executable Finding Access Database When Shipped

P

pooba53

I've seen several posts in the archives regarding making your VB .NET
application have a relative path connection string to an Access DB, but
do not see a definite resolution to the matter.

Here's what I'm trying to resolve:

My VB 2003 .NET application connects and works just fine with an Access
database located at c:\data.mdb. Now, I use a wizard for making an
installer for my application and it places the data.mdb file in the
installation directory without any problems.

However, I'm always going to have a runtime error unless the data.mdb
file is at c:\. I have to believe this issue has come up before and a
pro can easily shed some light on how I can perhaps use a relative path
in my connection string rather than an absolute.

I sure appreciate the help.

-Dan
 
O

Otis Mukinfus

I've seen several posts in the archives regarding making your VB .NET
application have a relative path connection string to an Access DB, but
do not see a definite resolution to the matter.

Here's what I'm trying to resolve:

My VB 2003 .NET application connects and works just fine with an Access
database located at c:\data.mdb. Now, I use a wizard for making an
installer for my application and it places the data.mdb file in the
installation directory without any problems.

However, I'm always going to have a runtime error unless the data.mdb
file is at c:\. I have to believe this issue has come up before and a
pro can easily shed some light on how I can perhaps use a relative path
in my connection string rather than an absolute.

I sure appreciate the help.

-Dan

Put the connection string to the Access DB in the App.Config file and stop hard
coding it into the application. That way you can set the path the file in the
config file to point to the location of the file. Search the documentation for
App.Config and connection string. Also search the documentation for application
settings.

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 
P

pooba53

Put the connection string to the Access DB in the App.Config file and stop hard
coding it into the application. That way you can set the path the file in the
config file to point to the location of the file. Search the documentation for
App.Config and connection string. Also search the documentation for application
settings.

Good luck with your project,

Otis Mukinfushttp://www.arltex.comhttp://www.tomchilders.com

I searched and searched and still found no definitive answer. Can
somebody simply illustrate how you deal with the location of your
Access db to your VB .NET executable when shipping application?

Thanks.
 
R

RobinS

pooba53 said:
I searched and searched and still found no definitive answer. Can
somebody simply illustrate how you deal with the location of your
Access db to your VB .NET executable when shipping application?

Thanks.

So you are trying to figure out where you Access db is after installing the
application on someone's desktop? How are you installing it? Do you specify
that in your installation?

It's hard for me to believe there's not some kind of setting that tells you
that. These are from looking through the My and Environment namespaces. I
don't nkow if they will work, but it's worth a try? I would tend to put it
in the same folder as my application, but I understand that's not a good
idea with Vista.

I think you have to use ClickOnce to use this; I don't know if it *sets*
the datadirectory or *gets* it or both.

my.Application.Deployment.DataDirectory

These seem to point to the same folder:

Environment.CurrentDirectory
My.Application.Info.DirectoryPath

This one probably points to the ApplicationData folder under the user's
Documents and Settings.

Environment.SpecialFolder.ApplicationData

This one probably points to the LocalApplicationData folder under the
user's Document and Setings.

Environment.SpecialFolder.LocalApplicationData

I do not know if these are available under .Net 1.1. I think the My
namespace is new with .Net 2.0, but the others are not.

I hope this helps in some way.

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
 

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