RTC Forums

Subscription => Support => Topic started by: agsoft on February 24, 2010, 01:48:57 AM



Title: RtcDataSetToDelphi Bug Fix:can not modified readonly field
Post by: agsoft on February 24, 2010, 01:48:57 AM
Readonly Field,Such as MSSQL Identity Seed Field,Will raise error "can not modified readonly field"!

Fix Code:

=======================
.........................................
=======================


Title: Re: RtcDataSetToDelphi Bug Fix:can not modified readonly field
Post by: D.Tkalcec (RTC) on February 24, 2010, 02:19:26 AM
Since this particular unit is NOT included in the RealThinClient SDK package, but is provided only as an example on how data *could* be copied from a TDataSet to a TRtcDataSet and back, I am quite sure there is a lot of space for improvements. But, I am not sure that changing a ReadOnly property of a Field in order to change its Value is a clean solution. I think an exception is more appropriate there, because it is not normal if your code wants to write to a ReadOnly property.

Also, since you seem to be concerned about performance (see the other thread), I am wondering why you would suggest a solution which will be changing the ReadOnly property of a Field to FALSE and then back to TRUE for every single Record which needs to be updated instead of doing it ONCE before the for loop and ONCE after the loop - which is, IMO, better done from the code calling the function and not inside the function, since doing it inside the function will only hide the fact that the code which is calling this function has a bug (it wants to change values of a readonly field).

Best Regards,
Danijel Tkalcec


Title: Re: RtcDataSetToDelphi Bug Fix:can not modified readonly field
Post by: agsoft on February 24, 2010, 02:29:42 AM
If you use MSSQL Identity Seed Field,You can know it.

I think if transfer dataset to dataset,the best way is:

[Server] CDS(ClientdataSet)->Stream->Transfer-> [Client]-> Stream To Olevariant ->CDS.Data := Olevariant Data.


Title: Re: RtcDataSetToDelphi Bug Fix:can not modified readonly field
Post by: D.Tkalcec (RTC) on February 24, 2010, 02:43:09 AM
Also ...

I don't mean to imply that you did this intentionally, but ... please do NOT post parts of the RealThinClient SDK code in the forums, because this is copyrighted material. By posting it here, you are breaking your license agreement. Yes, this also goes for short code segments and small functions for which you only want to offer a bugfix.

If you find a BUG in the RealThinClient SDK, please send your "BUG report" directly by E-Mail to:
(http://www.realthinclient.com/supportmail.gif)
... as explained in the "Found a bug?" section on the RTC SDK price/order page:
http://www.realthinclient.com/order.htm

Best Regards,
Danijel Tkalcec


Title: Re: RtcDataSetToDelphi Bug Fix:can not modified readonly field
Post by: D.Tkalcec (RTC) on February 24, 2010, 02:48:36 AM
Yes, I think that most developers who are working with a TClientDataSet on both ends are sending their data as a TStream, because TClientDataSet is capable of preparing a "delta" which can be easily used by another TClientDataSet to apply all edits, inserts and updates - remotely.

Best Regards,
Danijel Tkalcec


Title: Re: RtcDataSetToDelphi Bug Fix:can not modified readonly field
Post by: agsoft on February 24, 2010, 02:54:46 AM
I am sorry, i delete code now!


Title: Re: RtcDataSetToDelphi Bug Fix:can not modified readonly field
Post by: D.Tkalcec (RTC) on February 24, 2010, 03:11:10 AM
Thank you.

Best Regards,
Danijel Tkalcec


Title: Re: RtcDataSetToDelphi Bug Fix:can not modified readonly field
Post by: agsoft on March 19, 2010, 03:39:29 AM
last version you modify RtcDataSetToDelphi,Add the code  " DataSet.Post" method.
(Since this particular unit is NOT included in the RealThinClient SDK package, but is provided only as an example on how data *could* be copied from a TDataSet to a TRtcDataSet and back, I am quite sure there is a lot of space for improvements.)

I garde rtc sdk,must override my modified rtcDBTypes.pas! I feel very trouble!

Maybe you dont understand my mean!

some fields is readonly field,It cannot assign value.
If it is a readonly Field,I set the field property readonly is false,after assign value,I will set the field property readonly is True.
It only assign field value ,but dont modify the field property!!!
you can test the readonlyfield,such as TAutoIncField.

good luck, Guys!


Title: Re: RtcDataSetToDelphi Bug Fix:can not modified readonly field
Post by: D.Tkalcec (RTC) on March 19, 2010, 11:29:41 AM
As I have explained already, the "rtcDBTypes" unit is NOT part of the RTC SDK package. It is only an example which you can use to implement your own functions for copying data between a TRtcDataSet and a TDataSet. You should NOT directly use the "rtcDBTypes.pas" unit from your projects. Instead, you should write your own version of these functions, inside your own unit, which would work with your specific database components.

To avoid further confusion and make it clear that the "rtcDBTypes" unit is NOT part of the RTC SDK, but that it is ONLY an example, the "rtcDBTypes.pas" unit can now be found inside the "Demos\DataProviders" folder in the RealThinClient SDK 3.78 and later (now ready for download from RTC SDK PRO Downloads area) and NOT in the "Lib" folder (where it does not belong in the first place).

Best Regards,
Danijel Tkalcec


Title: Re: RtcDataSetToDelphi Bug Fix:can not modified readonly field
Post by: agsoft on March 19, 2010, 03:06:36 PM
OK, I Will Write my rtcDBTypes.pas in my project!
I am sorry ,maybe you should let rtcDBTypes.pas into the Lib folder!


Title: Re: RtcDataSetToDelphi Bug Fix:can not modified readonly field
Post by: D.Tkalcec (RTC) on March 19, 2010, 03:15:56 PM
No. The rtcDBTypes unit was placed in the Lib folder because I did not know of a better place to put it. But it does not belong to the Lib folder because it is not part of the RTC SDK. It is nothing more than an example on how one could copy data from a TRtcDataSet to a TDataSet and back. By keeping that unit out of the Lib folder, I am clearly showing that it is nothing more than a demo.

If you are working with a database, you will also need a database connection pool as well as other functions for working with Database components, so it only makes sense that you write your own unit where you will place all your database-specific functions.

Best Regards,
Danijel Tkalcec