Merging Data Tables in C#

by pencilvac 3/9/2012 12:16:00 PM

Merging data tables in C# is incredibly easy. If you have two tables of data pulled from the database:

In this situation our two tables have the same columns.

using System.Data; //include in your code behind so you can use data tables.

 

DataTable dt = Contract.GetDealContracts(pCompanyID, -1,42);

DataTable dt2 = Contract.GetDealContracts(pCompanyID, -1, 40);

 

 

You can then merge the two tables into one by simply:

dt.Merge(dt2); // table1.Merge(table2);

 

BOOM- two tables, now one table, with all your data. 

Tags: , , ,

.NET | ASP.NET Enterprise Library

C# Check for Null Querystring

by ebarcza 7/7/2011 3:54:00 AM
 if (Request.QueryString["ContractID"] != null && Request.QueryString["ContractID"].ToString() !="")
            {
                int contractID = int.Parse(Request.QueryString["ContractID"].ToString());
                Contract contract = new Contract(contractID);
                hdnContractID.Value = contractID.ToString();
                LoadForm(contract);
            }

Tags: , ,

.NET

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  May 2019  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

Recent comments

Tags

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2019

Sign in