RTC Forums
March 28, 2024, 08:34:14 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Updating tables on the server  (Read 2997 times)
classic12
Guest
« on: November 22, 2011, 08:43:16 PM »

In my ios app I can now bring data from the server's mysql and populate various editboxes with the data.

Once the data is edited in a text field I need to I now need to update this in the Mysql tables.

I presume I the simplest way is to:

1 Populate a MYdataset with data from the edit boxes.
2 Create a server app to receive the data asDataSet
3 Use RTCDataSetToDelphi
4 Update the Mysql table.

Is there a sample project for this?
With 2 should I create another server.exe or add the functionality to the existing server app?

Cheers


SteveW
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: November 22, 2011, 10:12:57 PM »

I see no reason why you should create a 2nd Server for receiving updates from Clients when you already have a Server which is sending you data based on your SQL queries. Simply add a new remote function to your Server (new TRtcFunction component), connect it to the TRtcFunctionGroup (just like you have done for the 1st function, which is sending datasets to Clients) and call that new function from the Client when you have updates ready for the Server.

How you want to handle changes on the Client side, how you want to send these changes to the Server and how you want to make updates on the Database is entirely up to you. By using RTC remote functions, you can send data back and forth. But what you do with that data is "your beer".

Naturally, you can use newRecord or newDataSet to send information about Client-side changes from your Client to your Server. Client would call a remote function preparing all changes in a newRecord/newDataSet and the Server will get the same data in the OnExecute event of a TRtcFunction which you implement there.

Another option it to use the TRtcMemDataSet component on the Client, after which you will need to change the "Data.DB" unit from the "uses" clause to "DB", so the Project compiles with FPC/Xcode. Because FireMonkey for iOS doesn't have support for DB Live Bindings, you will also need to make all changes to the TRtcMemDataSet component in code (can't simply link Edit fields with DB fields from the dataset), but ... you can then use TRtcMemDataSet's "TrackChanges" property along with the "OnDataChange" event and the "ExtractChanges" method to prepare changes for the Server.

For an example on using the TRtcMemDataSet component and its "ExtractChanges" method on the Client, please take a look at the "FishFactClient" Project (DB_Access folder). For examples on processing these changes on the Server, please refer to the "FishFactServer" (how to apply changes to a custom dataset - like TRtcMemDataSet), "FishFactServer2" (how to apply changes to a BDE Table) and "BDEDemoServer" Projects (more complex example on using the BDE).
 
PS. The "RtcDataSetToDelphi" procedure will copy the contents of a TRtcDataSet to any in-memory DataSet (create all field definitions and insert all records). It is NOT intended for applying changes directly to a Database. Applying changes to a Database requires manual coding, but it doesn't usually require copying the contents of a TRtcDataSet into another in-memory DataSet, unless you already have functions which would execute update/insert/delete operations on a Database Table based on rows inside an in-memory DataSet. For more details on how changes *could* be applied to a Database on the Server, please take a look at "FishFactServer2" and "BDEDemoServer" Projects from the "Demos/DB_Access" folder.

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.022 seconds with 16 queries.