Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW SHOULD I SETUP THE PATH TO THE MDB IN MY VB6/ACCESS2K APP

Status
Not open for further replies.

Hiccup

Programmer
Jan 15, 2003
266
0
0
US
My setup is VB6/Access2K. I'm using DataGrids connected via Adodc's to the Access mdb file.

When I run the PD Wizard, create the Setup.exe file and install the program everything works fine on the PC I created the VB app on, but when I run the Setup file on another PC, I always run into the familiar message: "Can't find the mdb file" because of the path I created with the Adodc.

I'm missing something basic here I know, but how do I setup the path to the mdb file so that the Setup.exe file will work on any PC the program is installed on?

The Setup runs ok on the other PC and the VB app is installed fine, but when trying to use the newly installed program, the "Can't find Path" problem occurs.

I guess what I'm asking is where should I be putting the Access mdb, so that the installed app will work properly with the Access database when I install the program on a different PC?

Any suggestions will be greatly appreciated!!!
 
How are you setting up your ADODC? If you set it up through code you could use something like:

With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Supplier.mdb;Persist Security Info=False"
.RecordSource = "SELECT * FROM Master ORDER BY [Promail Job Number] ASC;"
End With

Swi
 
Thanks Swi, I've been building the connections by right-clicking on the Adodc control and selecting properties. Then, in the properties window, I browse to the mdb file then select the mdb Table I want. The resultant connection string looks like:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\ehicks\Desktop\PDWTEST\PDWTEST.mdb;Persist Security Info=False.

The problem is with this part of the string:

C:\Documents and Settings\ehicks\Desktop\PDWTEST\PDWTEST.mdb

Obviously, this will be different on someone else's PC we try to install the app on and this is where the problem comes up.
 
That is why you may want to try using the App.path:

.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\PDWTEST.mdb;Persist Security Info=False"

Swi
 
Swi - What does replacing the C:\Documents and Settings\ehicks\Desktop\PDWTEST in my string with your "&App.Path&" do for me?

How does it point the program to the mdb file? I'm confused!
 
Hiccup,
App.Path will resolve to the Path where the actual .EXE (Application) is running. (Note it lacks a traling "\", you will need to add it manually as on Swi's sample code. Therefore, if you have your DB file physically there as well you will be always able to locate it. (Unless you have some other fix directory where you go and find it, say a network drive.) Also please note that you can have any other directory structure after the App.Path value (ie.: App.Path & "\Data\MyDB.MDB")
Use the VB Help to look at the App object, it provides some other information that is also valuable.

Goodluck,
pepito609
 
Thanks pepito609! I'm confused, Swi DOES have a backslash after "&App.Path&"\. Where exactly do I add the \ to Swi's code that you're suggesting?; at the end of the string like this:

.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\PDWTEST.mdb;Persist Security Info=False"\
 
Thanks Swi, I checked your link, but I'm still confused as to where pepito609 is saying to manually add the backslash to you code! At the very end like I'm showing above? I don't think that's where I put it.
 
In a new project add the following code:

Private Sub Command1_Click()
MsgBox App.Path
End Sub

You will see that at the end of the string it does not put a \. Therefore you would get something like:

C:\Program Files\Microsoft Visual Studio\VB98PDWTEST.mdb

You would want to add a backslash in order to accomodate for this:

C:\Program Files\Microsoft Visual Studio\VB98\PDWTEST.mdb

That is why my code above has a backslash before Supplier.mdb:

With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Supplier.mdb;Persist Security Info=False"
.RecordSource = "SELECT * FROM Master ORDER BY [Promail Job Number] ASC;"
End With

Swi
 
You may want to do a check though because if they install the app on a root drive you could end up with C:\\ if you hardcode the backslash. Something like the following would take care of that issue:

IIf(Right$(App.Path, 1) = "\", App.Path, App.Path & "\")

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top