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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Path Error when install on another machine

Status
Not open for further replies.

webcrazy

Instructor
Dec 24, 1999
14
US
I built my first VB 6 program with an Access Data Base using the Data control.
When I try to install it on a different PC using the package and deployment wizard, if I change the installation path it does not find the data base.

How can I fix this so the user can choose the installation path and still have VB connect to the Data base?

NB/ I built my data base in access 2000 & then connected it to VB with the Data controller and I'm using VB 6 Enterprize Edition.

I would appreciate any help in this matter.
 
Did you set the path to the database at designtime or do you specify the path at runtime?
If you specify the path at runtime, you should always be able to connect to the database nomatter what directory the database is in.

Herman :-Q
 
Hi HermanvLimbeek,

I set the path at design time...how do I set it at run time?
I would appreciate your help on this.

Web
linkskig@yahoo.com
 
Well, it depends on the control you are using. If it's a ADO data control, look in the properties of the control and copy the value of connectionstring (Ctrl+C). Then go to the form_load event and paste the connectionstring into a variable, e.g. ConnectionString. It should look something like this:


Private Sub Form_Load()

Dim ConnectionString As String
Dim YourPath as String
Dim YourDB as String
YourPath = App.Path 'specify the database path
YourDB = "MyDB.mdb"
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= " & YourPath & YourDB

With Adodc1
.RecordSource = _
"SELECT * FROM Table1" 'specify the table
.ConnectionString = ConnectionString
.Refresh
.Caption = "Table1 values"
.Visible = False
End With
End Sub

I'm not sure if this connectionstring is right for Access2000, but it should help you on your way.

Herman :-Q
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top