TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ekrem Tapan
NA
967
81.2k
when use SQLBULKCOPY if record exist how can i update ?
Apr 8 2016 2:30 AM
hello everybody,
im using excel table import to sql,
if i already have a same record how can i update it then continue import other data ?
DataTable dt = new DataTable();
dt.Columns.Add("SHEET", typeof(int));
dt.Columns.Add("DATE", typeof(DateTime));
dt.Columns.Add("DATA", typeof(string));
dt.Columns.Add("CODE", typeof(string));
IRow excelRow = default(IRow);
excelRow = sheet.GetRow(0);
for (int Cel = 1; Cel <= excelRow.LastCellNum - 1; Cel++)
{
var cellValue = excelRow.GetCell(Cel);
for (int k = 1; k <= sheet.LastRowNum - 1; k++)
{
string code = cellValue.ToString();
var date = sheet.GetRow(k).GetCell(0);
var value = sheet.GetRow(k).GetCell(Cel);
string dates = date.ToString();
string values = value.ToString();
dt.Rows.Add(b, dates, values, code);
}
}
cnn.Open();
SqlBulkCopy bulkCopy = new SqlBulkCopy(cnn);
bulkCopy.DestinationTableName = "RMQ_DATA";
bulkCopy.WriteToServer(dt);
cnn.Close();
Reply
Answers (
1
)
How to Calculate Employee System (PC) Working Hours
Using Recursion I Want to Display the list of Contents to th