Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How will I ever get my app ported to SQL Server?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01338696
Message ID:
01341973
Views:
20
Matt,

My apologies for the delay in responding to you on this -- I've been out of pocket for a few days.

There's no particular "right way". You can certainly fill the cursor with code in the Init() of the DE -- no worries there. You could also fill them later in the Init() of the form, or in the form's Activate event. All would work fine *depending on the circumstances*.

What you might want to consider is *when* you actually need that data, and when *exactly* you plan to bind the data elements of the CA (or assign them, whichever) to your form controls. You shouldn't just automatically populate the cursor at the beginning and expect to have meaningful data -- remember, it might have changed during the time that your form was loading other stuff (not likely in the large majority of cases, but still possible if you're loading a big form with lots of metadata and say, a PageFrame with six pages each holding lots of controls).

If I was using your "form + DE" approach, I might lean towards using "late binding" by setting the form's BindControls property to false by default. Then, usually in the Init or Activate event of the form (if the data needs to be refreshed every time the form is entered, use the Activate, if not use the Init), I'd fire a method which fills the cursor(s), assigns the desired values and (if it's the first time into the form) sets BindControls to true.

From that point forward, if I ever need to reassign, I'd just call the same method again. If I was using containers or behavior classes to control the interface, I'd never instantiate them until they're needed, so the populate method fires upon instantiation of the container or behavior class, and can be re-fired as needed just the same as the form method.

This approach keeps all your code that fills cursors and populates controls in a single place (I actually call that method by the name xPopulateDataControls in each development-level class where it comes into play) regardless of whether you use form methods, container methods or behavior classes to control the user interface.

HTH.

Evan

>I started some basic testing, and need a little help to make sure I am off to the right start here...
>
>(P.S.. I've already played with creating a DE class and separate CA classes (with Mark McCasland's CA Builder9 tool), and I plan to use that method for production, but for now, I am just experimenting in IDE mode to make sure I get the vision of this stuff, and get the basic mechanics working)
>
>
>So...
>
>I created a new form in the IDE using my base form, and I went to View->Data Environement of the form, and did right-click on the DE window area and picked Builder, then added the ODBC connection data on the Data Source tab, and then clicked on the Cursors tab, then clicked New to create a CA in the right in the forms DE. I set the "Use DataEnvironment data source" flag, and chose a table and fields from the SQL Server connection. I also gave it a Name and an Alias.
>
>So now I have a CA in the form's DE.... Next I ran the (mostly empty) form, but I got no cursor opened up in the Data Session dialog box. It is not opening the CA that I added to the DE!
>
>The only way I found to make it work is to add code in the DataEnvironment.init() method, like this: "this.Jobs.cursorfill()".
>
>So, is that the right way to open up and populate the CAs, by adding code in the init() of the DE?
>
>I guess I kindof expected it to open them since they were there.
Evan Pauley, MCP
Positronic Technology Systems LLC
Knoxville, TN

If a vegetarian eats vegetables, what does a humanitarian eat?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform