TClientDataSet x TMSQuery
TClientDataSet x TMSQuery
Hello, I'm testing the component SDAC 5.10 for Delphi 7 Trial and I have some doubts.
1. DataSetProvider contains events BeforeUpdateRecord and AfterUpdateRecord. These events are called for each record before and after submitting changes. These events have UpdateKind variable that allows you know if the record has been modified, inserted or deleted (ukModify, ukInsert, ukDelete).
I did not find these events in TMSQuery.
2. TClientDataSet ChangeCount has property that indicates the number of records changed. TMSQuery ChangeCount hasn’t the property ChangeCount, only Modified (TDataSet). Is there any other property that indicates the number of rows changed?
3. Is SDAC compatible with Delphi 2010 DataSnap? I couldn’t do this teste yet.
I am analyzing these details to buy SDAC component in the future and these questions will be determining factors for the acquisition. I have no doubt that this is the best component for native access to SQL Server.
Thanks.
1. DataSetProvider contains events BeforeUpdateRecord and AfterUpdateRecord. These events are called for each record before and after submitting changes. These events have UpdateKind variable that allows you know if the record has been modified, inserted or deleted (ukModify, ukInsert, ukDelete).
I did not find these events in TMSQuery.
2. TClientDataSet ChangeCount has property that indicates the number of records changed. TMSQuery ChangeCount hasn’t the property ChangeCount, only Modified (TDataSet). Is there any other property that indicates the number of rows changed?
3. Is SDAC compatible with Delphi 2010 DataSnap? I couldn’t do this teste yet.
I am analyzing these details to buy SDAC component in the future and these questions will be determining factors for the acquisition. I have no doubt that this is the best component for native access to SQL Server.
Thanks.
Hello,
1. You can use the BeforeUpdateExecute and AfterUpdateExecute events of the TMSQuery component. These events occur before and after executing insert, delete, update, lock and refresh operations. To determine the exact operation that has been executed, you can use the StatementTypes set of variables. Here is an example:2. You can use the RowsAffected property that indicates the number of rows, which were inserted, updated, or deleted during the last query operation.
3. Yes, SDAC is compatible with DataSnap. Please take a look at the example of using Datasnap components in the Midas demo. You can find this demo in the %SDAC_Install_Directory%\Demos\Miscellaneous\Midas directory.
1. You can use the BeforeUpdateExecute and AfterUpdateExecute events of the TMSQuery component. These events occur before and after executing insert, delete, update, lock and refresh operations. To determine the exact operation that has been executed, you can use the StatementTypes set of variables. Here is an example:
Code: Select all
procedure TMainForm.MSQueryBeforeUpdateExecute(Sender: TCustomMSDataSet;
StatementTypes: TStatementTypes; Params: TMSParams);
begin
if stInsert in StatementTypes then
//your code
else
if stDelete in StatementTypes then
//your code
else
if stUpdate in StatementTypes then
//your code
end;
3. Yes, SDAC is compatible with DataSnap. Please take a look at the example of using Datasnap components in the Midas demo. You can find this demo in the %SDAC_Install_Directory%\Demos\Miscellaneous\Midas directory.
Hello AndreyZ,
1. Question answered, but did not find the event equivalent to the BeforeApplyUpdates and AfterApplyUpdates of the TClientDataSet. That are executed only once, before and after submitting changes.
2. RowsAffected property, the value returned is always 1, even having more records changed. This is a bug? This property is populated after applying the changes. In TClientDataSet, ChangeCount is populated with each post or delete it, that is, before sending the changes. I used a TMSQUery with CachedUpdates enabled. Follow the code:
3. I will still check out the example of DataSnap.
1. Question answered, but did not find the event equivalent to the BeforeApplyUpdates and AfterApplyUpdates of the TClientDataSet. That are executed only once, before and after submitting changes.
2. RowsAffected property, the value returned is always 1, even having more records changed. This is a bug? This property is populated after applying the changes. In TClientDataSet, ChangeCount is populated with each post or delete it, that is, before sending the changes. I used a TMSQUery with CachedUpdates enabled. Follow the code:
Code: Select all
MSConnection.StartTransaction;
MSQuery.ApplyUpdates;
MSConnection.Commit;
ShowMessage(IntToStr(MSQuery.RowsAffected));
1. We've discussed this question, but considered implementing these events superfluous. If you think otherwise, you can leave your suggestion concerning these events at http://devart.uservoice.com/forums/1046 ... components , and if many people vote for it, we will implement it.
2. It's a correct behaviour. The point is that SDAC executes a query for every record thas has been changed. That's why the RowsAffected property returns 1. The RowsAffected returns a value greater than one after the last query inserted, updated, or deleted more than one record on the server.
2. It's a correct behaviour. The point is that SDAC executes a query for every record thas has been changed. That's why the RowsAffected property returns 1. The RowsAffected returns a value greater than one after the last query inserted, updated, or deleted more than one record on the server.
Hello again,
I did some testing and it seems that using the TClientDataSet with TMSQuery works perfectly. (TMSConnection + TMSQuery + TDataSetProvider + TClientDataSet).
Can I work this way without risk?
The scenario that was put together the following:
1. TMSConnection used to connect to the database;
2. I turned on the TMSQuey + TMSConnection and filled the property "UpdatingTable" with the name of the table that the update will occur;
3. I turned on the TDataSetProvider + TMSQuery and changed the property "poAllowCommandText" to TRUE;
4. I turned on the TClientDataSet + TDataSetProvider the CommandText property and used a query with JOIN.
This way everything worked.
I noticed that the set automatically TMSQuery what are the keys in the table. Is there a way to do this at run-time?
Thank you.
I did some testing and it seems that using the TClientDataSet with TMSQuery works perfectly. (TMSConnection + TMSQuery + TDataSetProvider + TClientDataSet).
Can I work this way without risk?
The scenario that was put together the following:
1. TMSConnection used to connect to the database;
2. I turned on the TMSQuey + TMSConnection and filled the property "UpdatingTable" with the name of the table that the update will occur;
3. I turned on the TDataSetProvider + TMSQuery and changed the property "poAllowCommandText" to TRUE;
4. I turned on the TClientDataSet + TDataSetProvider the CommandText property and used a query with JOIN.
This way everything worked.
I noticed that the set automatically TMSQuery what are the keys in the table. Is there a way to do this at run-time?
Thank you.
Yes, you can work this way.Can I work this way without risk?
If you want to specify the key fields for the TMSQuery component, you can use the KeyFields property for this. For more information about the KeyFields property, please read the SDAC documentation.I noticed that the set automatically TMSQuery what are the keys in the table. Is there a way to do this at run-time?