DataTable dtdata = new DataTable();
dtdata.Columns.Add("EscalationIssueId", typeof(Guid)); //Primary key
dtdata.Columns.Add("EscalationId", typeof(Int32));
dtdata.Columns.Add("IssueId", typeof(Int32));
dtdata.Columns.Add("CreatedOn", typeof(DateTime));
dtdata.Columns.Add("CreatedBy", typeof(string));
for
(int k = 0; k < 10; k++)
{
DataRow dr = dtdata.NewRow();
dr["EscalationIssueId"] = new Guid();
dr["EscalationId"] = Convert.ToInt32(escaltionID);
dr["IssueId"] = Convert.ToInt32(lsulist[k]);
dr["CreatedOn"] = DateTime.Now;
dr["CreatedBy"] = "Arun
Aravind";
dtdata.Rows.Add(dr);
}
}
System.Data.SqlClient.SqlBulkCopy oSqlBulkCopy = new System.Data.SqlClient.SqlBulkCopy((System.Data.SqlClient.SqlConnection)conn);
conn.Open();
oSqlBulkCopy.DestinationTableName
= destinationTableName;
oSqlBulkCopy.WriteToServer(sourceDataTable);
conn.Close();
oSqlBulkCopy.Close();
If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)
No comments:
Post a Comment