RTC Forums
November 25, 2024, 02:35:49 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: RtcDataSetToDelphi Bug Fix:can not modified readonly field  (Read 8409 times)
agsoft
Newbie
*
Posts: 15


« 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:

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


« Reply #1 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
Logged
agsoft
Newbie
*
Posts: 15


« Reply #2 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.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 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:

... 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
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #4 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
Logged
agsoft
Newbie
*
Posts: 15


« Reply #5 on: February 24, 2010, 02:54:46 AM »

I am sorry, i delete code now!
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #6 on: February 24, 2010, 03:11:10 AM »

Thank you.

Best Regards,
Danijel Tkalcec
Logged
agsoft
Newbie
*
Posts: 15


« Reply #7 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!
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #8 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
Logged
agsoft
Newbie
*
Posts: 15


« Reply #9 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!
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #10 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
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.028 seconds with 17 queries.