I want to insert new data and update existing one using sqlbulkcopy method.
I have created methods that will always insert records and hence duplicate data are available in table
string ConnectionString = Utility.GetLocalDBConnStr(dbConnModal);
DataTable dt = Utility.ToDataTable(UsersList);
using (SqlConnection connection = new SqlConnection(ConnectionString))
{
SqlBulkCopy bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.TableLock |
SqlBulkCopyOptions.FireTriggers | SqlBulkCopyOptions.UseInternalTransaction, null);
bulkCopy.DestinationTableName = "User";
connection.Open();
bulkCopy.WriteToServer(dt);
connection.Close();
res = true;
}
How to achieve this thing? Please suggest any way.