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.
Unidac,delphi xe4 and mysql
-
DemetrionQ
- Devart Team
- Posts: 271
- Joined: Wed 23 Jan 2013 11:21
Re: Unidac,delphi xe4 and mysql
Hello.
To read data from the table with TUniQuery, you should run a SELECT query, e.g.:
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.:
2) Run a data modifying SQL query directly, e.g.:
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.
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;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;Code: Select all
UniQuery1.SQL.Clear;
UniQuery1.SQL.Add('update YourTable set YourFiled = ''data1'' where id_field = 1');
UniQuery1.ExecSQL;
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
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.
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
If any other questions come up, please contact us.