Real Software Forums

Generically populating database fields to window controls
Page 1 of 1

Author:  superjacent [ Wed Apr 17, 2013 3:22 am ]
Post subject:  Generically populating database fields to window controls

I'm seeking some insight into a project in which I'm attempting to re-write Microsoft Access code.

The project involves database activity and will be retaining connection to MS Access mdb's. There are numerous base tables for traditional stuff such as, names, addresses, phones, log entries (these are all tables in their own right) plus a heap of other base tables. Heaps of secondary linking tables (ie. contacts - link - phones etc.) I mention this as there will be lots and lots of separate windows.

I'm attempting to be as generic as possible with the process of populating window controls (textfields, checkboxes etc.) with data from the associated SQL statements (recordsets). I've already developed classes to handle the SQL side of things.

Here's what I've come up with to date: I'm thinking to sub-class all relevant window controls (textfield, textarea, checkbox etc.), at a minimum add string properties, named, TableName & FieldName. The purpose being that these controls will contain the name of the field from the table. At the class level, cycle through the sub-classed controls, retrieve the value of the field from the table and populate the window control.

I'd like to know if I'm on the right track. What other methods or process could be employed to be as generic as possible?

Author:  Bob Keeney [ Wed Apr 17, 2013 9:46 am ]
Post subject:  Re: Generically populating database fields to window control

You can do it that way. I've worked on a few projects that have done that.

I found them to be a serious pain. Don't get me wrong, creating generic subclasses that handled the data in and out of the controls was no big deal, it was all the edge cases that caused no end of grief. Text fields and the like are no big deal but it was the Listboxes that were almost impossible to code properly.

Real Studio database classes are pretty generic - almost too generic. Data binding at the control level doesn't really help you much, IMO, because the data conversion still has to be done to get it into and out of the database. We created ActiveRecord to make that a bit easier and to let the IDE help us (auto complete and datatype checking). More on ActiveRecord at Using AR we usually do generic Load, Save, Validate functions on our window/pages and that's worked well for us.

Author:  superjacent [ Thu Apr 18, 2013 11:32 pm ]
Post subject:  Re: Generically populating database fields to window control

Thanks Bob.

Yes, the Listbox is a pain.

I checked out your ActiveRecord page which has given me some clues. Always nice to have another perspective.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group