Recent

Author Topic: Adding or Inserting datta into a MySQL Table  (Read 5964 times)

thaimann

  • Jr. Member
  • **
  • Posts: 84
Adding or Inserting datta into a MySQL Table
« on: May 07, 2005, 03:12:15 pm »
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

matthijs

  • Hero Member
  • *****
  • Posts: 537
Adding or Inserting datta into a MySQL Table
« Reply #1 on: May 07, 2005, 03:35:54 pm »
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: [Select]

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

Then it is just a matter of assigning the texts from the EditBoxes to the values of the parameters and call ExecSQL.
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

thaimann

  • Jr. Member
  • **
  • Posts: 84
Adding or Inserting datta into a MySQL Table
« Reply #2 on: May 07, 2005, 06:15:37 pm »
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 :(

 

TinyPortal © 2005-2018