Question Best practice re viewing/changing single records on a form

RegJ

Member
Joined
Aug 21, 2014
Messages
6
Programming Experience
10+
Hi,

I have an application where I'm using MDI child forms to display lists of records (which is working ok). By double-clicking a row in some tables I want to open up a non-child form showing the data retrieved for a single record, allow the user to change it, then save it. One small complication is that the data for each row actually comes from 3 tables, 1 a SQL Server table, then 2 via ODBC.

I thought the best approach might be to create a class containing a list of "fields", then fill the fields using datareaders for the 3 data sources. I then thought I would be able to bind each "field" to a control on the form, but I can't seem to make that work nor find any examples that do it.

Do, am I going about this entirely the wrong way?

Ms Access/VBA now seems so easy ..... :cold:

Cheers
Reg
 
When the user double-clicks the row in the child form, how much of the data do you already have and how much do you need to retrieve? Presumably you must have some of the data already but it also sounds like you don't have all of it.

I would pretty much forget about data-binding if you're only dealing with one record at a time. You can use a data reader to read one record and put the data directly into the controls and then, after the changes have been made, take the data directly from the controls and populate the parameters of an ADO.NET command. It's not necessarily a bad idea to define a type that represents the combined data in a single object but it's fairly pointless if you have the data access code in the form. If you're going to add some architecture to separate out the data access then I'd be all for it.
 
I have a small amount of the data in the child form, and ID, a name and 2 codes which are actually keys into 2 tables in the odbc database (Sage 50 Customer and Supplier tables). This part of the application is about allowing my user to edit both a Sage Customer and Supplier record via one window (they deal with people who are often both a customer and a supplier).

So, in the edit form, I have code to retrieve both Sage records.

Thanks for the reply. I will follow your advice.

Cheers
Reg
 
Back
Top