Thanks Dave. So are controls on the form like textboxes bound to the cursor or Thisform.oData_Obj ?
Ajoy Khaund On Tue, Jun 24, 2014 at 9:15 PM, Dave Crozier <[email protected]> wrote: > First Point to any record of the data held in a cursor (usually done in > the Load of the form where you can get the data structure) > > * Create a data Object > Thisform.AddProperty("oData_Obj", null) > * > * Populate the data object inc memo fields but with blank data > oObj=Thisform.oData_Obj > scatter name oObj memo blank > > The object Thisform.oData_Obj will then contain a list of properties > relating to each field name in the cursor > e.g try opening the oObj in the debugger and you will see the properties > > ? oObj.<character_field_1> > > so you end up with Properties like: > oObj.Customer_Id > oObj.Primary_Key ... etc etc > > The addition of the word blank after the scatter simply initializes the > object with field properties containing no data. > > When you come to disperse the data back to your underlying tables, in VFP > assuming you are pointing at the correct record to update it is simple done > by: > > oObj=Thisform.oData_Obj > * > select <cursor> > gather name oObj memo > > Once again gon't gorget the word memo or any binary/blob or memo fields > will not be gathered. > > You can use the same technique to update the SPT cursor for committing to > the non DB table. > > Dave > > > > > -----Original Message----- > From: ProFox [mailto:[email protected]] On Behalf Of Ajoy Khaund > Sent: 24 June 2014 15:51 > To: profox > Subject: Re: Data Entry Form using Sql Server & SPT > > Dave, > Thanks for the write up. I got it going. There were some hiccups ofcourse. > > How do you create a data object? > > Do you create a class with all fields of the table as properties? > > Please let me know as I want to make the same form in all the ways > possible and then choose which I like best. > > Initially I liked CA's but then found SPT to be easier. > > Thanks > > Ajoy Khaund > > > On Tue, Jun 24, 2014 at 2:07 PM, Dave Crozier <[email protected]> > wrote: > > > Ajoy, > > The usual procedure of using a "data object" which is an object > > containing the current, or in the case of a new record, a blank set of > data is used. > > You do the changes to the data object by binding the object properties > > to the form controls (textbox etc) and then you can freely manipulate > > the data in your program using business logic to validate the fields > > and then commit the object for writing to the database - or adding if it > is a new record. > > > > I won't go into the areas of Biz objects at this time as it opens up a > > whole area of discussion but simply but in simple terms you > > > > 1. Load the form > > > > 2. In the form init() create an object property to hold the current > > record or blank record as an object with properties and bind the > > object properties to the form controls. > > > > 3. Get the data record from the underlying table then Scatter the data > > from the record into the form "data object". You can scatter a blank > > record which will set the data object up for insertion (see scatter > > blank memo) > > > > 4. Enter/Modify and/or validate the data object properties using > > standard controls on the form as the data will now be bound to the form > controls. > > Nothing is written away to the DB at this time and only the data > > object is modified > > > > 5. If you want to write the data back to the DB then gather the data > > back from the form "data object" and write/commit it to the underlying > DB table. > > > > In this way you can use the same logic on VFP or SQL remote data as > > the only change needed is the rear/write functions. You can do this > > using SPT or Table adapters. Personally I don't like TA's, but this is > > just my opinion. > > > > Please don't take this as the only way top do it as I am just trying > > to show you how you need to separate the data from the underlying > > database by loading it into an object upon which you perform all the > > data manipulation/verification etc before writing it away. > > > > Dave > > > > [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/CAPs4RvU8wd+5NOpaqfkpDvbp5Du6-20=V5cG=6xk_klxef1...@mail.gmail.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

