C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,991 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have Dataset and trying to move into SQL Server table using Bulk Option. What is the problem in the loop.
The loop (top loop) will be executing first time and inserting the record into the table without any error. where as the looping (top loop) the second time, i am getting the below error.
ERROR : System.InvalidOperationException : 'The given ColumnMapping does not match up with any column in the source or destination.'
EmpNo
Salary
Department
for (int i = 1; i <= 10; i++)
{
con.Open();
bulk.DestinationTableName = "tblEmployee";
foreach (DataColumn col in DataSet.Tables[0].Columns)
bulk.ColumnMappings.Add(col.ColumnName, col.ColumnName);
bulk.WriteToServer(DataSet.Tables[0]);
con.close();
}
pls. give us the guidance where is the problem in the above code.
Try executing bulk.ColumnMappings.Clear( ) before con.Open( ).