本文介绍了读取asp.net中的数据集合并两个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个桌子
1.table1(id,name,ReorderQuantity)
2.table2(iid,Quantity,BadQuantity)
我想将上述表格合并到一个数据集中.
I have two tables
1.table1(id,name,ReorderQuantity)
2.table2(iid,Quantity,BadQuantity)
I want to merge aboves tables in one dataset.
推荐答案
string query_login = "select * from Login";
SqlConnection con = new SqlConnection(conn);
SqlDataAdapter da_login = new SqlDataAdapter(query_login, con);
DataSet ds_login = new DataSet();
da_login.Fill(ds_login);
string query_user = "select * from user";
SqlDataAdapter da_user = new SqlDataAdapter(query_user, con);
DataSet ds_user = new DataSet();
da_user.Fill(ds_user);
ds_login.Merge(ds_user);
Select table1.name, table1.ReorderQuantity, table2.Quantity, table2.BadQuantity
from table1, table2 where table1.id = table2.id
上面的查询将返回4列,并借助dataadapter使用上面的结果填充数据集.
above Query will returns 4 columns, fill dataset using above result with the help of dataadapter.
这篇关于读取asp.net中的数据集合并两个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!