Page 1 of 1
Unidac,delphi xe4 and mysql
Posted: Mon 27 May 2013 15:08
by chaithika
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.
Re: Unidac,delphi xe4 and mysql
Posted: Tue 28 May 2013 12:19
by DemetrionQ
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.
Re: Unidac,delphi xe4 and mysql
Posted: Thu 30 May 2013 18:15
by chaithika
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.
Re: Unidac,delphi xe4 and mysql
Posted: Fri 31 May 2013 09:25
by DemetrionQ
If any other questions come up, please contact us.