Forum > Databases

Adding or Inserting datta into a MySQL Table


This may be a stupid question :oops:   and I am sure it has been asked elsewhere (but I can't find it.)   :(

As I understand it, when you want to update or insert data into a MySQL Table, you need to use the ExecSQL statement (I would also like to see an example of one of these.)  But what I don't understand is how can you relate this to the data-aware objects on my forms.

Example,  Lets say I want to allow the user to alter a record, how do I allow them to alter the contents of a DBEdit(remember, its read only, right?)  

Also, if you allow yur user to insert a record, how  are you going  to set  all of your data-aware componets to blank and allow your user to enter the new record?

Thx,            Terry

It is a bit more work: Don't use DBAware components. In Delphi I always build specific forms for data entry and use plain edit-boxes to display the data to the user. When data needs to be entered use an SQL-statement with parameters like:

--- Code: ---
  SQL.Text := 'UPDATE MyTable ' +
              'SET ' +
              'Field1 = :Field1 ' +
              'Field2 = :Field2 ' +
              'WHERE ' +
              'IdField = :IdField';

--- End code ---

Then it is just a matter of assigning the texts from the EditBoxes to the values of the parameters and call ExecSQL.

I have been using DAC for MySQL with Delphi 7.  I am sorry, but the Lazarus MySQL interface is terrible.
I think the Lazarus gui has a lot of potential, but for my needs, it is not there yet.  

Terry :(


[0] Message Index

Go to full version