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

Using Dataenvironment with cursors

Status
Not open for further replies.

wsobers

IS-IT--Management
Dec 2, 2000
43
BB
I build my reports by generating cursors first and then running the report form.
I was hoping to run the cursor generation code in the init or opentable event of the DataEnvironment, but it seems as though the DE needs to reference file based tables and cannot use in-memory cursors. Can anyone verify this?
using VFP90.

Wayne
 
the visual part of the DE can only open tables, but your idea to put code in the OpenTables() method should work.

What problems do you have?

Maybe not opened the correct database your code needs before opening/running the report? Either add an OPEN DATABASE line to the code or do it before running the report. Any table object in the DE implicitly opens the underlying database. If you have no table in the DE you of course cannot rely on your database being open...

report controls must refer to either full qualified alias.fieldname or if you use fieldname only expressions, make SELECT alias the last command of your OpenTables() method. That correspnds to the InitialSelectedAlias property of the DE.

Bye, Olaf.
 
Hi Wayne,

Just for the record a report can use as its input table a cursor created in the INIT event or the OpenTables method of the DE.

Jim
 
Olaf, there are no databases involved.
What I am doing is creating cursors on the fly and populating them with data from XML and CSV sources. In some cases the data is being passed via OLE/COM interfaces.
I want to avoid explicitly creating temp tables on the users machine which is why I am using "create cursor".

In order to actually build the report, I want to create a sample source file on disk, and have it opened and processed in the data environment of the report. That way I can pick and select fields when designing the report and I only need to change the source of the data when I deploy the report.

I tried to create a DE using define class in a PRG file and then tried to set the report to use the program DE. But it has not worked so far. This is the first time I am trying this so its quite possible that I've messed things up. Time to try again.
Thanks for the responses.
Wayne
 
Here is the class I ended up with.

*File: orderdde.prg
define class orders as DataEnvironment
*
initialselectedalias = "orderd"
*
procedure init
do ordload
this.opentables()
endproc

procedure opentables
select orderh
index on orderno tag orderno
select orderd
index on orderno tag orderno
set relation to orderno into orderh
endproc

procedure destroy
this.closetables()
endproc

procedure closetables
select orderd
set relation off into orderh
use in orderh
use in orderd
endproc
enddefine
*----------
"do ordload" creates the cursors, populates them and leaves them open.
Next I created a new report and then tried to "Report|Load Data Environment"
After selecting the file "orderdde.prg" and the class, I get the following error.

"variable OBJTYPE not found, Line 0 in loadcromclass()"

If I create a "newobject" I end up with the cursors defined and I can modify the report and choose fields. But none of the fields are in the DE. It makes it more troublesome to create reports beause I can't use drag and drop. But at least I can edit the report.

Wayne
 
Hi Wayne,

Let's look at it from scartch:
You have a table at development that makes it easy for you to pick fields for report controls. Okay.

Then at runtime you want cursors to act as this table you had at development. Okay

You can simply do so by removing everything from the DE. If cursors are created outside of the report, before running the report, the report will gladly work on that cursors.

And to have the report running without a prerun of a cursor creation script or whatever, you simply need to do whatever you need in the Init or TableOpen() Method of the empty DE of your report.

No DE class or whatever needed.

Bye, Olaf.


 
Olaf

Sorry for butting in on this one but it seems that I have a very similar problem to wayne's and (I'll admit to my own lack of knowledge here) feel i am missing something fundamental.

i am not a foxpro programmer I am a data analyst, analysing foxpro databases which may have huge bearing on my lack of understanding

the problem I have is that i used to put the tables in the DE of a report but found it slowed things down with large data sets so i started creating cursors that gave the report its info.

then obviously i lost the ability to drag and drop [fields] into the report which meant that end users were no longer able to amend a report themselves and had to phone me up every time time they wanted a slight adjustment.

As you can probably appreciate, this is a major problem to me as it means that i have to personally rework their report (which can be a lengthy resource issue if i have to do this over the telephone).

Are you aware of anything that I can look into that will allow me to have the drag and drop functionality but still allow me to use cursors rather than [real] tables to do this??

Sorry to butt in on somebody else's post but (I may be wrong but it sounds like wayne and i are talking about something similar) and I can tell from this forum that you know much more than me so any help/direction will be appreciated.

Thanks
 
Olaf,
The problem you describe is exactly why I tried to use the DE in the first place. I used Foxpro way before the DE was added to the product and I always pre-generated the data into a single cursor because:
a) If there where problems with the report I could put the cursor data into a table and check it.
b) If indexes where messed up (which could happen with win9X and flaky networks) again I could view it by running the cursor to a table instead of the cursor.
c)I don't need to worry about where to store my temp files. Foxpro takes care of all temp file creation and removal.

What I ended up doing was building a program to create the DE and put in a #define statement for development or production mode.
In development mode, the DE beforeopentables event creates tables which can be used in the DE to drag and drop fields.
In production mode, the same DE creates cursors only.

Olaf, as you are not a programmer, it might save you time if you got a product which was geared towards end-user development like the stonefield report writer.
Hope this helps

Wayne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top