If you have remote users connecting to your database server who need to make changes to the data, you might want to set up a briefcase application, depending on what exactly they do with the data. This article will help you set one up using Delphi, MySQL, and an XML file.
Briefcase Applications Explained - Applying Changes to the Data (Page 4 of 4 )
So far we have covered how to retrieve data from the server, and how to store and make changes to that data. The final thing we need to do is apply those changes back to the server. We do this by simply calling the "applybatch()" function. So, double click on the button with the caption "Apply changes to Server" and add the following code:
procedure TForm2.btnapplyClick(Sender: TObject); begin // Connect to MySQL, load savedata.xml and send changes to MySQL form1.q.Connection := form1.ADOConnection1; form1.q.UpdateBatch(arAll); end;
This code connects to the server:
form1.q.Connection := form1.ADOConnection1;
Then calls the "UpdateBatch(arAll)" command:
form1.q.UpdateBatch(arAll);
Which updates the server with the changes.
Conclusion
There are some things that I have not covered in this article, such as conflict resolution. For example I did not address the question of how to detect if a record has been changed by someone else before you apply your updates. I've not experimented enough to work that out yet. Ultimately, you will have to decide what you want to do in those circumstances, but at the end of the day, the records will be overwritten one way or the other.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.