I find that you often need to create and manipulate standalone rowsets. Sometimes you can get the data for your standalone rowset from the database using the Fill method, however sometimes you'll want to copy from existing rowsets. This is where the CopyTo method comes in handy.

However there is one important thing to note when using CopyTo - it will only copy like-named record fields and subscrolls at corresponding levels

In order to work correctly, the record in the source rowset must have the same name as the record in target rowset, unless you specify a record list in the parameters.

For instance, say I have data in a rowset &rsExample with one record, EXAMPLE which is populated in the component buffer.

The EXAMPLE record has the following fields:

  • EMPLID
  • NAME

Now, say I want to copy the data from my rowset &rsExample to another rowset, &rsExampleAudit which consists of an audit record forEXAMPLE called AUDIT_EXAMPLE.

The AUDIT_EXAMPLE record has the following fields:

  • AUDIT_OPRID
  • AUDIT_STAMP
  • AUDIT_ACTN
  • EMPLID
  • NAME

What I want is to copy the like-name fields between &rsExample and &rsExampleAudit (the fields EMPLID and NAME).

The following code will NOT work:

&rsExample.CopyTo(&rsExampleAudit)

Why? Because &rsExample consists of a record named EXAMPLE, but &rsExampleAudit consists of a record named AUDIT_EXAMPLE. Because the two rowsets do not have the same underlying record name, the copy does absolutely nothing (quite frustrating!).

In this scenario, we need to specify a record list, so it knows the source and target record names. This how I need to write this code to make it work:

&rsExample.CopyTo(&rsExampleAudit, Record.EXAMPLE, Record.AUDIT_EXAMPLE)

Generically the syntax is:

&rsSource.CopyTo(&rsTarget, Record.SOURCE_RECNAME, Record.TARGET_RECNAME)

Copying Rowsets的更多相关文章

  1. 14——小心copying行为

    资源的copying行为决定对象的copying行为. 抑制copying行为,使用引用计数.

  2. UVa 714 Copying Books(二分)

    题目链接: 传送门 Copying Books Time Limit: 3000MS     Memory Limit: 32768 KB Description Before the inventi ...

  3. Effective C++ -----条款14: 在资源管理类中小心copying行为

    复制RAII对象必须一并复制它所管理的资源,所以资源的copying行为决定RAII对象的copying行为. 普遍而常见的RAII class copying行为是:抑制copying(使用私有继承 ...

  4. ACM: Copying Data 线段树-成段更新-解题报告

    Copying Data Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description W ...

  5. 抄书 Copying Books UVa 714

    Copying  Books 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=85904#problem/B 题目: Descri ...

  6. Copying Fields to a new Record

    This is a time saving tip for application designer. If you are creating a new record definition and ...

  7. UVA 714 Copying Books 二分

    题目链接: 题目 Copying Books Time limit: 3.000 seconds 问题描述 Before the invention of book-printing, it was ...

  8. poj 1505 Copying Books

    http://poj.org/problem?id=1505 Copying Books Time Limit: 3000MS   Memory Limit: 10000K Total Submiss ...

  9. [Effective C++ --014]在资源管理类中小心copying行为

    第一节 <背景> 条款13中讲到“资源取得的时机便是初始化时机”并由此引出“以对象管理资源”的概念.通常情况下使用std中的auto_ptr(智能指针)和tr1::shared_ptr(引 ...

随机推荐

  1. jsLint配置参数解释

    转自: http://www.cnblogs.com/elementstorm/archive/2013/04/10/3012679.htmlanon :true //匿名函数声明中function关 ...

  2. expdp和impdp的用法

    源地址:http://blog.chinaunix.net/uid-23622436-id-2394094.html

  3. Java SE 第十六讲----面向对象特征之多态

    1.多态:polymorphism:我们说的子类就是父类(玫瑰是花,男子是人),因此多态的意思就是:父类型的引用可以指向子类的对象 public class PolyTest { public sta ...

  4. 出现java.lang.NoClassDefFoundError: com/google/common/base/Charsets异常错误

    使用selenium,出现java.lang.NoClassDefFoundError: com/google/common/base/Charsets异常错误 原因:selenium-server- ...

  5. RDLC报表分页显示标题

    将报表以 XML的方式打开,搜索找到“详细信息” 在这个位置 <TablixRowHierarchy> <TablixMembers> <TablixMember> ...

  6. [SQL]多列的行转列

    create table t(name varchar(),subject varchar(),mark int) insert into t union all union all union al ...

  7. (整理)streamWriter、streamReader与FileStream

    今天偶然使用VS代码分析,发现CA2000警告,然后其中一条为streamWriter.streamReader与FileStream相关内容,特查询并记录一下. 引文地址:http://bbs.cs ...

  8. Grunt 之 RequireJS

    RequireJs 提供了一个打包工具 r.js,可以将相关的模块打包为一个文件.相关说明:http://www.requirejs.org/docs/optimization.html 将相关的脚本 ...

  9. 使用AS3.0代码实现给图片添加滤镜的模糊与斜角效果

    滤镜可应用于任何显示对象(即,从 DisplayObject 类继承的对象), 例如 MovieClip.SimpleButton.TextField 和 Video 对象,以及 BitmapData ...

  10. 把数组转换成sql中能使用的字符串

    1.数组对象转换成字符串,拼接成符合sql语句的语法 2.代码如下例子 public static void testString(){        String[] str=new String[ ...