10 Replies - 14286 Views - Last Post: 31 May 2006 - 09:33 PM Rate Topic: -----

#1 StephanBotha  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 55
  • Joined: 12-March 06

App.Path Error when Compiled

Posted 31 May 2006 - 09:17 AM

Hi There,

First off, here is the code:

	Dim strDBPath As String
	
	strDBPath = App.Path
	
	If Right(strDBPath, 1) <> "\" Then
		datAgents.DatabaseName = App.Path & ".\IPM-DB.mdb"
	End If



I use this to find my MS Access DB file. When I use the Package & Deployment wizzard and install the program on the same PC where my Visual Studio is installed I don't get any errors.

When I install it on another PC WITHOUT Visual Studio installed I get the error:

"Provide cannot be found. It may not be properly installed". I almost smacked my screen off the desk. I remember this error from 3 years ago when I use code in VB a lot.

Is this because I havn't installed DotNet SDK 1.1 on the other PC?

I know the piece of code I pasted above is the reason for the error, coz if I remove it and set the databasename/connectionstring to C:\Program Files\IPM\, i don't get no errors. This is not good coding so I don't wanna do it.

Please help!

Is This A Good Question/Topic? 0
  • +

Replies To: App.Path Error when Compiled

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: App.Path Error when Compiled

Posted 31 May 2006 - 09:26 AM

Although you do not need the SDK on both computers, you do need to have the .NET Framework installed for your application to work on any other computer.

Here is where you can get the Redistributable Package.

You only need the SDK if you are going to be creating the applications on both computers.
Was This Post Helpful? 0
  • +
  • -

#3 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: App.Path Error when Compiled

Posted 31 May 2006 - 09:39 AM

jayman makes an important point....net applications require the .net framework to run...it, or an emulator, is required on every client machine upon which the application will run.
Was This Post Helpful? 0
  • +
  • -

#4 StephanBotha  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 55
  • Joined: 12-March 06

Re: App.Path Error when Compiled

Posted 31 May 2006 - 09:58 AM

OK,

I downloaded and installed the .Net Framework 2.0 from the link you guys gave me. Still the error. I also realised that the error is only generated on the forms which uses ADODC data control. The forms with the normal data control works fine (Add, Edit, Delete, Display).

I am ready to take out my boxing gloves. :cry2:

This post has been edited by StephanBotha: 31 May 2006 - 10:04 AM

Was This Post Helpful? 0
  • +
  • -

#5 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: App.Path Error when Compiled

Posted 31 May 2006 - 10:50 AM

Check your connection string and make sure you are using the correct provider. For MS Access it is like this:
Me.conPayables.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;data source=C:PathToYourDatabaseFile\yourdatabase.mdb"



Unless these are ADO objects, then check the properties of the connection object and make sure it points to the correct location from either computer.
Was This Post Helpful? 0
  • +
  • -

#6 StephanBotha  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 55
  • Joined: 12-March 06

Re: App.Path Error when Compiled

Post icon  Posted 31 May 2006 - 11:08 AM

I've already done that. It still doesn't explain why it works on a computer with VB6 installed and NOT on a computer without it. Both computers have .NET Framework 2.0 installed. The program's installation was successfull and the .mdb file is in the Application's Directory. All the forms without an ADODC control works fine. Only the one with the ADODC control gives me this error. I've received this error 3 years ago and stopped coding in VB6 because I couldn't find a solution. I hoped it was because of the .NET Framework. I am totally hopeless again.

Here is the code to find the .MDB file for the FORM which gives the error.

	Dim iRecords As Integer
	
	Dim strDBPath As String
	
	strDBPath = App.Path
	
	If Right(strDBPath, 1) <> "\" Then
		datAgents.ConnectionString = App.Path & ".\IPM-DB.mdb"
		datClients.ConnectionString = App.Path & ".\IPM-DB.mdb"
		datPortfolios.ConnectionString = App.Path & ".\IPM-DB.mdb"
		datInvestments.DatabaseName = App.Path & ".\IPM-DB.mdb"
	End If



The error is on the "datAgents.ConnectionString" lines. All of them being ADODC controls.

:cry2:

This post has been edited by StephanBotha: 31 May 2006 - 11:22 AM

Was This Post Helpful? 0
  • +
  • -

#7 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: App.Path Error when Compiled

Posted 31 May 2006 - 11:25 AM

When you use the Package and Deployment Wizard, you are presented with options of things you would like to include. Have you ensured that you are including the ADODC library controls?
Was This Post Helpful? 0
  • +
  • -

#8 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: App.Path Error when Compiled

Posted 31 May 2006 - 01:50 PM

Based on your first post of the error message

Quote

"Provide cannot be found. It may not be properly installed".
the problem seems to be that your application cannot find the data provider. You may need to adjust your code as follows:

Dim iRecords As Integer
	
	Dim strDBPath As String
	
	strDBPath = App.Path
	
	If Right(strDBPath, 1) <> "\" Then
		datAgents.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & ".\IPM-DB.mdb"
		datClients.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & ".\IPM-DB.mdb"
		datPortfolios.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & ".\IPM-DB.mdb"
		datInvestments.DatabaseName = App.Path & ".\IPM-DB.mdb"
	End If


Was This Post Helpful? 0
  • +
  • -

#9 StephanBotha  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 55
  • Joined: 12-March 06

Re: App.Path Error when Compiled

Post icon  Posted 31 May 2006 - 08:42 PM

It doesn't help. For some reason my code just all of a suddon doesn't work anymore. My default path for my database is "D:\My Documents\Stephan\My Projects\IPM\IPM-DB.mdb". When I use Package and Deployment wizzard to create a setup program and install the program, my path to the database changes to C:\Program Files\IPM\IPM-DB.mdb"

The piece of code I submitted should be able to do that, but it doesn't. It should find the path the Application (EXE) is in and use that path to find the DB? Is this correct? :blink:
Was This Post Helpful? 0
  • +
  • -

#10 StephanBotha  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 55
  • Joined: 12-March 06

Re: App.Path Error when Compiled

Posted 31 May 2006 - 08:46 PM

After I installed the program to test it, it still looks for the database in the first location (D:\My Documents\Stephan\My Projects\IPM). It's ignoring the code I entered to look for the databse in the application's directory.

I get an error msg for every ADO Data Control. :crazy:
Was This Post Helpful? 0
  • +
  • -

#11 StephanBotha  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 55
  • Joined: 12-March 06

Re: App.Path Error when Compiled

Posted 31 May 2006 - 09:33 PM

I followed Amadeus' advice. I added the MSADODC.ocx file to my list of files to add and the error:

"Provider cannot be found. It may not be properly installed" doens noet come up anymore. Now I need to set the path for the DB in realtime. If user changes the installation path from the default: "C:\Program Files\IPM" to something else, the program won't be able to find the database. When I set the path in code I get the another error when accessing my datacontrol. For some reason the App.Path code I pasted doesn't work anymore. It seems like VB is ignoring that piece of code. Why?

Stephan :crazy:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1