Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 108983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:59:52+00:00 2026-05-11T01:59:52+00:00

I have a DataSet populated from Excel Sheet. I wanted to use SQLBulk Copy

  • 0

I have a DataSet populated from Excel Sheet. I wanted to use SQLBulk Copy to Insert Records in Lead_Hdr table where LeadId is PK.

I am having following error while executing the code below:

The given ColumnMapping does not match up with any column in the source or destination

string ConStr=ConfigurationManager.ConnectionStrings['ConStr'].ToString();  using (SqlBulkCopy s = new SqlBulkCopy(ConStr,SqlBulkCopyOptions.KeepIdentity)) {     if (MySql.State==ConnectionState.Closed)     {         MySql.Open();     }      s.DestinationTableName = 'PCRM_Lead_Hdr';     s.NotifyAfter = 10000;      #region Comment     s.ColumnMappings.Clear();      #region ColumnMapping     s.ColumnMappings.Add('ClientID', 'ClientID');     s.ColumnMappings.Add('LeadID', 'LeadID');     s.ColumnMappings.Add('Company_Name', 'Company_Name');     s.ColumnMappings.Add('Website', 'Website');     s.ColumnMappings.Add('EmployeeCount', 'EmployeeCount');     s.ColumnMappings.Add('Revenue', 'Revenue');     s.ColumnMappings.Add('Address', 'Address');     s.ColumnMappings.Add('City', 'City');      s.ColumnMappings.Add('State', 'State');     s.ColumnMappings.Add('ZipCode', 'ZipCode');     s.ColumnMappings.Add('CountryId', 'CountryId');      s.ColumnMappings.Add('Phone', 'Phone');     s.ColumnMappings.Add('Fax', 'Fax');     s.ColumnMappings.Add('TimeZone', 'TimeZone');     s.ColumnMappings.Add('SicNo', 'SicNo');     s.ColumnMappings.Add('SicDesc', 'SicDesc');      s.ColumnMappings.Add('SourceID', 'SourceID');     s.ColumnMappings.Add('ResearchAnalysis', 'ResearchAnalysis');     s.ColumnMappings.Add('BasketID', 'BasketID');     s.ColumnMappings.Add('PipeLineStatusId', 'PipeLineStatusId');      s.ColumnMappings.Add('SurveyId', 'SurveyId');     s.ColumnMappings.Add('NextCallDate', 'NextCallDate');     s.ColumnMappings.Add('CurrentRecStatus', 'CurrentRecStatus');     s.ColumnMappings.Add('AssignedUserId', 'AssignedUserId');     s.ColumnMappings.Add('AssignedDate', 'AssignedDate');     s.ColumnMappings.Add('ToValueAmt', 'ToValueAmt');     s.ColumnMappings.Add('Remove', 'Remove');     s.ColumnMappings.Add('Release', 'Release');      s.ColumnMappings.Add('Insert_Date', 'Insert_Date');     s.ColumnMappings.Add('Insert_By', 'Insert_By');     s.ColumnMappings.Add('Updated_Date', 'Updated_Date');     s.ColumnMappings.Add('Updated_By', 'Updated_By');      #endregion     #endregion      s.WriteToServer(sourceTable);      s.Close();      MySql.Close(); } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:59:53+00:00Added an answer on May 11, 2026 at 1:59 am

    Well, is it right? Do the column names exist on both sides?

    To be honest, I’ve never bothered with mappings. I like to keep things simple – I tend to have a staging table that looks like the input on the server, then I SqlBulkCopy into the staging table, and finally run a stored procedure to move the table from the staging table into the actual table; advantages:

    • no issues with live data corruption if the import fails at any point
    • I can put a transaction just around the SPROC
    • I can have the bcp work without logging, safe in the knowledge that the SPROC will be logged
    • it is simple ;-p (no messing with mappings)

    As a final thought – if you are dealing with bulk data, you can get better throughput using IDataReader (since this is a streaming API, where-as DataTable is a buffered API). For example, I tend to hook CSV imports up using CsvReader as the source for a SqlBulkCopy. Alternatively, I have written shims around XmlReader to present each first-level element as a row in an IDataReader – very fast.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Related Questions

No related questions found

Sidebar

Ask A Question

Stats

  • Questions 58k
  • Answers 58k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer If the file is opened with sharing permissions then you… May 11, 2026 at 8:36 am
  • added an answer Installing libssh2 via tar.gz from http://sourceforge.net/projects/libssh2/ help a lot (--with-ssh2=/usr/local/include/).… May 11, 2026 at 8:36 am
  • added an answer You can use Debugview from Sysinternals/Microsoft http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx May 11, 2026 at 8:36 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.