Click here to Skip to main content
16,016,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have two tables
1.table1(id,name,ReorderQuantity)
2.table2(iid,Quantity,BadQuantity)
I want to merge aboves tables in one dataset.
Posted
Comments
rajeevcapgeminiindia 24-Nov-11 1:36am    
What kind of merge - DataSet containing single table as per some specific condition or DataSet containing to seperate tables without any condition.

C#
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);
 
Share this answer
 
 
Share this answer
 
You can use Inner join in SQL to fetch result and then fill dataset.
your Query may be like this

SQL
Select table1.name, table1.ReorderQuantity, table2.Quantity, table2.BadQuantity
from table1, table2 where table1.id = table2.id 


above Query will returns 4 columns, fill dataset using above result with the help of dataadapter.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900