Unidac,delphi xe4 and mysql

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
chaithika
Posts: 2
Joined: Mon 27 May 2013 14:56

Unidac,delphi xe4 and mysql

Post by chaithika » Mon 27 May 2013 15:08

hi

im using delphi RAD studio XE4 and mysql as DB. and use unidac 5.0 as Data access component. i need to know that what is the best way of using unidac for read, insert, update and delete operations. im using "TUniQuery".

thank you.

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Unidac,delphi xe4 and mysql

Post by DemetrionQ » Tue 28 May 2013 12:19

Hello.

To read data from the table with TUniQuery, you should run a SELECT query, e.g.:

Code: Select all

  UniQuery1.SQL.Clear;
  UniQuery1.SQL.Add('select * from YourTable');
  UniQuery1.Open;
To update data in the table, you can use one of the following:

1) Open the table using the above SQL query and modify data with standard methods of TDataSet - Edit, Post, Insert, Delete, e.g.:

Code: Select all

  // UniQuery1 already opened
  UniQuery1.Insert;
  UniQuery1.FieldByName('YourFiled').AsString := 'New data';
  UniQuery1.Post;
2) Run a data modifying SQL query directly, e.g.:

Code: Select all

  UniQuery1.SQL.Clear;
  UniQuery1.SQL.Add('update YourTable set YourFiled = ''data1'' where id_field = 1');
  UniQuery1.ExecSQL;
TUniQuery is inherited from the standard TDataSet class, and the described data modifying and viewing methods are the standard operations, therefore you can get the detailed information in the TDataSet class documentation (e.g. here: http://docwiki.embarcadero.com/Librarie ... B.TDataSet ).

You can also see the "Updating data with UniDAC" article in the UniDAC documentation - this topic describes common approaches of data editing with dataset components of UniDAC.

chaithika
Posts: 2
Joined: Mon 27 May 2013 14:56

Re: Unidac,delphi xe4 and mysql

Post by chaithika » Thu 30 May 2013 18:15

Hi DemetrionQ

thank you for your reply. i have used second approach. after UniQuery1.SQL.Add i have called UniQuery1.Prepare. after that assign values to the query. then call UniQuery1.Execute procedure instead UniQuery1.ExecSQL.

thank you.

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Unidac,delphi xe4 and mysql

Post by DemetrionQ » Fri 31 May 2013 09:25

If any other questions come up, please contact us.

Post Reply