RobinS
Thu Feb 15 16:44:31 CST 2007
"pooba53" <pooba53@gmail.com> wrote in message
news:1171320305.640658.99870@j27g2000cwj.googlegroups.com...
> On Jan 25, 6:48 am, Otis Mukinfus <phoney.email.addr...@phoney.com>
> wrote:
>> On 24 Jan 2007 10:38:38 -0800, "pooba53" <poob...@gmail.com> wrote:
>>
>>
>>
>> >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.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.
>
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.