是否有任何vay将一些记录的副本插入到同一个表中? [英] Is there any vay to insert copy of some records to same table?

查看:67
本文介绍了是否有任何vay将一些记录的副本插入到同一个表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。



我的桌子上有很多记录,我需要那些,还需要那张桌子上的那些记录的副本。

我使用linq,我可以用它来插入身份问题。据说这个主键已经存在。

例如:

  var  myRecords = 来自 i   db.tMytable 
其中i.name.Contains( A
select i;





我怎样才能将这些记录预览到新的身份表主键?



提前谢谢。

解决方案

我如何通过新身份主键记录预览表?





如果只是显示数据两次,则无需在表格中插入重复数据,只需按照以下指南





 OleDbConnection con =  new  OleDbConnection(); 
con.ConnectionString = 此处的连接字符串;
con.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = 选择*来自dbo_NR_HMSWD50SQ_01_147;
OleDbDataAdapter adp = new OleDbDataAdapter(cmd.CommandText,con);

// 创建两个数据表

DataTable ds = new DataTable();
DataTable ds1 = new DataTable();

// 用相同数据填充

adp.Fill(ds);
adp.Fill(ds1);

// 将它们合并到一个数据表

ds.Merge(ds1);

// 并显示在gridview中

dataGridView1.DataSource = ds;







我希望这对你有帮助.......


Hi every one.

I have many records in my table, i need those and also need a copy of those records in that table.
I use linq, and i can use it for insert coz of identity problem. Is said this primary key already exists.
For example :

var myRecords = from i in db.tMytable
Where i.name.Contains("A")
select i;



how can i these record to previews Table by new identity Primary key ?

Thanks in advance.

解决方案

how can i these record to previews Table by new identity Primary key ?


If it just about displaying the data twice then no need to insert duplicate data in your table simply follow the guidelines below


OleDbConnection  con = new OleDbConnection ();
con.ConnectionString = "your connection string here";
con.Open();
OleDbCommand cmd=new OleDbCommand();
cmd.CommandText = "Select * from dbo_NR_HMSWD50SQ_01_147";
OleDbDataAdapter adp = new OleDbDataAdapter(cmd.CommandText , con);
            
//Create two datatables

DataTable ds = new DataTable();
DataTable  ds1 = new DataTable();
           
//Fill them with same data

 adp.Fill(ds);
adp.Fill(ds1);

//merge them to one datatable

ds.Merge(ds1);

//and display in your gridview

dataGridView1.DataSource = ds;




I hope this helps you........


这篇关于是否有任何vay将一些记录的副本插入到同一个表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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