RTC Forums
November 25, 2024, 12:49:57 AM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Help
Login
Register
RTC Forums
>
Subscription
>
Support
>
Using TRtcDataSet / TClientDataSet to update DB.
Pages: [
1
]
« previous
next »
Print
Author
Topic: Using TRtcDataSet / TClientDataSet to update DB. (Read 6574 times)
markh51
Guest
Using TRtcDataSet / TClientDataSet to update DB.
«
on:
November 30, 2009, 02:18:07 AM »
I have a client / server application. I am unable to update my MSSQL db on the server side.
The goal is to pass a DataSet using TRtcDataSet to the client for use in a DbGrid then to be able to edit the grid then pass the data back to the server and update the DB.
I can get the data to the client and show it in the grid no problem, however I am not sure how to update the database once the data is passed back to the server. I am able to get the data back into a TClientDataSet, but not sure what to do with it.
I have looked and tried for hours but nothing seems to work. I tried using commands like ApplyUpdates, but this just "inserts" another record in my DB and does not update.
I am using MSSQL and ADO.
Any help is appreciated...
Logged
Walter
RTC License++
Posts: 16
Re: Using TRtcDataSet / TClientDataSet to update DB.
«
Reply #1 on:
December 01, 2009, 02:40:04 AM »
You will need to manage things. There is no automatic facility built - you are simply moving data back and forth from server to client to server.
When you get the data back at the server from the client and you Append(Insert) it into the TClientDataset - then that is why it gets Inserted (again) when you do ApplyUpdates.
You will need to create a mechanism on the client side (maybe add a field to each table) to keep a status - that the record was updated, inserted or deleted (don't do physical deletes - just mark the record - as you need to send back to the server the fact that a record was deleted) then when you send the data back to the server, you will need to interogate the Status and do Updates, Inserts or Deletes to the Client dataset as necessary before you ApplyUpdates.
This answer is to help you see that you need to create a management mechanism.
Walter
Logged
markh51
Guest
Re: Using TRtcDataSet / TClientDataSet to update DB.
«
Reply #2 on:
December 01, 2009, 10:09:09 AM »
ok, thanks. I'm not how to approach this as Im not to sure what to do with the TClientDataSet.
Logged
Kevin Powick
RTC Expired
Posts: 87
Re: Using TRtcDataSet / TClientDataSet to update DB.
«
Reply #3 on:
December 04, 2009, 07:41:37 PM »
As Walter indicated, you must devise an approach to the problem. You will keep track of the changes made on your client side and then send only those changes back to the server. Imagine the following:
- Client application requests 100 records which are used to populate the client side grid.
- The user of the client application changes (edits) 3 of the records and deletes one of them.
You must somehow get the information regarding those changes over to the server, so that your server side code can correctly update the database. How you decide to package up the information you plan to send to the server via one of your RTC function calls is up to you.
On the server side, I would probably just iterate through the data received from the client and execute the appropriate SQL
Update
and
Delete
statements.
Logged
Linux is only free if your time is worthless
markh51
Guest
Re: Using TRtcDataSet / TClientDataSet to update DB.
«
Reply #4 on:
December 05, 2009, 09:24:33 PM »
Thanks for the pointers guys.
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Dashboard
-----------------------------
=> General
=> 3rd-Party
=> Quick Start
-----------------------------
Subscription
-----------------------------
=> Support
Loading...