RTC Forums
May 28, 2024, 03:35:19 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
   Home   Help Login Register  
Pages: [1]
Author Topic: How to copy data from a TDataSet component into a TRtcDataSet object?  (Read 30072 times)
D.Tkalcec (RTC)
Posts: 1881

« on: September 03, 2011, 12:21:17 PM »

Here, you can find an example for a general-purpose function to copy data from a TDataSet descendant component into a TRtcDataSet structure for use with RTC Remote Functions. Please note that you might have to update the RTC_DB2FIELD_TYPE declaration depending on the Delphi version you are using, or chance the way you are mapping Delphi database field types to RTC database field types ...

  DB, rtcInfo;

{$include rtcDefs.inc}

  RTC_DB2FIELD_TYPE: array[TFieldType] of TRtcFieldTypes =
    ( ft_Unknown, ft_String, ft_Smallint, ft_Integer, ft_Word,
      ft_Boolean, ft_Float, ft_Currency, ft_BCD, ft_Date, ft_Time, ft_DateTime,
      ft_Bytes, ft_VarBytes, ft_AutoInc, ft_Blob, ft_Memo, ft_Graphic, ft_FmtMemo,
      ft_ParadoxOle, ft_DBaseOle, ft_TypedBinary, ft_Cursor, ft_FixedChar, ft_WideString,
      ft_Largeint, ft_ADT, ft_Array, ft_Reference, ft_DataSet
      {$IFNDEF IDE_0}
      ,ft_OraBlob, ft_OraClob, ft_Variant,
       ft_Interface, ft_IDispatch,ft_Guid
        {$IFNDEF IDE_1}
        , ft_TimeStamp, ft_FMTBcd
          {$IFDEF IDE_2006up}
            , ft_WideString, ft_WideString, ft_TimeStamp, ft_Variant
      {$ENDIF} );

procedure DelphiDataSetToRtc(DelphiDS:TDataSet; rtcDS:TRtcDataSet; ClearFieldDefs:boolean=True);
  if ClearFieldDefs then
    for flds:=0 to DelphiDS.FieldCount-1 do

  while not delphiDS.EOF do
    for flds:=0 to rtcDS.FieldCount-1 do
      if assigned(field) then


Even though the function shown above should work for most field types, it can NOT automatically recognize and translate all field types provided by all Database Access components. This is especially true for Memo and BLOB fields. To correctly extract your data from a TDataSet descendant component and copy that data to a TRtcDataSet component, you should use the code example provided above, give it a different name and modify your version to correctly copy all DB Field types you are using with Database Access components of your choice.

Best Regards,
Danijel Tkalcec
Pages: [1]
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.021 seconds with 16 queries.