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

Cursor Adaptor and DB path

Status
Not open for further replies.

AlastairOz

Technical User
Jul 27, 2010
81
AU
When I install my app and test on another computer, and install to say c:\program files\app\ I get error messages.
During development I used a different directory.
I have some code in the main prg that sets the path, so that works OK, the problem is with cursor adaptors.

I have used cursor adaptors throughout my application. They are all setup with data source type as native. Also has the path to the database. However the path to the database when
the app is installed is different.
Can I use some code in the main prg to give the cursor adaptors a variable path? What are my options?

 
There are a gazillion ways to configure an application. Ok, not literally, but you of course need some config file to determine a base path or a database path.

The specific problem with CA is the code the CA builder writes into init, see in your CA classes yourself:

Code:
...
local lcDBC
lcDBC = 'C:\USERS\OLAF\DOCUMENTS\VISUAL FOXPRO PROJECTS\CURSORADAPTER\DATA.DBC'
if dbused(lcDBC)
	set database to (lcDBC)
else
	open database (lcDBC)
endif
...

The good thing about that code is it does not repoen the database once it's already open, but it is opening the database in the path specified. You need to change that code of course.

Rather make that:
Code:
...
local lcDBC
lcDBC = goApp.oConfig.cDatabasepath
if dbused(lcDBC)
	set database to (lcDBC)
else
	open database (lcDBC)
endif
...

In a global Application object (goApp) you define in the main prg of your exe, you could have a sub object added by Addobject for configuration (oConfig) with properties holding the configuration data.

Besides, the original code can work in fact, if you really have a similar named database within SET PATH, the original code with the hardwired path in lcDBC would retry finding the DBC along those paths, so either you have an error in SET PATH or you set it too late.

Bye, Olaf.
 
Actually what I said about set path is only halfway true.
When you specify a full path for open database, like the cursoradapter builder does, it will not search for the database along the paths in SET('PATH')

What works is this:

Code:
* preparation
mkdir c:\test1\
mkdir c:\test2\
create database c:\test2\test.dbc
close databases all

* usage
set path to c:\test2\ additional
cd c:\test1\
open database test
? dbc() && will show c:\test2\test.dbc

So finding the database would work if the standard code of the CA init would CD to the path and then open database with the filename only.

You can make use of menu: Tools->Code References to search for the database path and replace it by removing the full path, only leaving databasename.dbc. Then you should CD to the path the database should be or SET PATH in the application main prg and that would work.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top