このコードはエラーです:
指定された ColumnMapping は、ソースまたは宛先のどの列とも一致しません。
空かどうかのチェック列がありますが、機能しません。
using (var bulkCopy = new SqlBulkCopy(destinationConnection))
{
//THIS A MAPPING REPLACET WITH YOUR NEED
for (int i = 0; i <18; i++)
{
if (datagridaddfield.Rows[i].Cells[1].Value != null)
{
bulkCopy.ColumnMappings.Add(datagridaddfield.Rows[i].Cells[0].Value.ToString(), datagridaddfield.Rows[i].Cells[1].Value.ToString());
bulkCopy.DestinationTableName = "profile2";
[...]
私はプログラムがこの行をチェックしたいのですif (datagridaddfield.Rows[i].Cells[1].Value != null)
が、プログラムはチェックしていません!