数据表合并无主键列 [英] DataTable merge without primary key column

查看:165
本文介绍了数据表合并无主键列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何合并其中的目标表包含犯规包含主键列和源表的表。数据集enforceConstraints设置为false,那么它会合并表。但是,当执行GetChanges()上的目标表异常发生。

  //目的地表包含在源表$缺少主键b 
$ b的DataSet DS;
DataTable的来源;
ds.EnforceConstraints = FALSE;
ds.Tables [目标]合并(来源真实,MissingSchemaAction.AddWithKey)。
ds.Tables [目标] GetChanges()。


解决方案

试过合并表没有主键。
我认为它是不可能的。


How to merge tables in which destination table contains primary key column and source table doesnt contain. DataSet enforceConstraints is set to false then it will merge the table. but when execute GetChanges() on destination table exception occurs.

//Dest table contains primary key which is missing in source table

        DataSet ds;
        DataTable source;
        ds.EnforceConstraints = false;
        ds.Tables["Dest"].Merge(source,true,MissingSchemaAction.AddWithKey);
        ds.Tables["Dest"].GetChanges();

解决方案

Have tried to merge tables without primary key. I think its not possible.

这篇关于数据表合并无主键列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆