Subject Re: [IBO] Re: Inserting New Rows - Long-winded?
Author Helen Borrie
At 08:39 a.m. 21/10/2013, robert_nixon@... wrote:
>Thanks for your quick reply, Helen. It seems a bit "wrong" to have a method that appears to ignore the SQL statement in the query, which is perhaps why I was looking in the wrong places, but it's very convenient.

It's the way all data access components for Delphi do their work. It's totally different to programming in native Paradox!

1. You get a dataset using a SELECT statement
2. If the dataset is "editable" (and there are database-engine-specific rules for this, besides ObjectPascal properties) then the DA components construct INSERT, UPDATE and DELETE statements automatically, which kick in when the mode (Insert/Edit/Delete) is changed by the Delphi application. (You can customise these statements in many component sets, including IBO, using the InsertSQL, EditSQL and DeleteSQL properties.)

>I was interested to see your commendation for using a data module. I tried this when I was using Paradox (yes, quite a while ago) and could not make it work without re-declaring everything, and I've seen someone do that with a proper RDBMS too. Is there a text available on how to make it work properly?

I'm sure there is - Google will know. Datamodules have been around since Delphi 2, afair, and were often the subject of conference presentations back in the day. But it's not rocket science at all. A datamodule is just another Delphi unit. You put your connections, datasources and datasets there (and ib_sessions, if you are using other than the default) and you put the datamodule's name into the uses clause of any forms that want to access it. Then, all the data access components on your datamodule are available in the selector lists on those forms.

It sounds as though you are a bit of a newbie in Delphi as well as IBO. You could do yourself a big favour by working through the sample apps that are installed with IBO....that said, I don't think Jason used datamodules in those projects. But, as I indicated before, using a DM is no different from using a form unit. It's just a very elegant way to separate your data layer from your user interface layer and to package up that DA layer for access by multiple form units (and other datamodule units, if you have them).

There is a miscellany of articles on the IBObject website that could help you through some of your "sticky" points. Also, I wrote a Getting Started Guide some years ago, that is still available in the IBO shop. It's very much a work-through of the principles of IBO and is *not* a general tutorial about data access in Delphi.

HTH
Helen