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

Posted by Tejamanimala under C# on 10/23/2013 | Points: 10 | Views : 13405 | Status : [Member] | Replies : 9
The given ColumnMapping does not match up with any column in the source or destination.
a few seconds ago|LINK

Hi i want to import the excel sheet into database,at the same time of importing am copying the data into table,2 excel sheets are imported and data is copied but when i try to import another excel sheet it showing error like this

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The given ColumnMapping does not match up with any column in the source or destination.

Source Error:


Line 88: //Give your Destination table name
Line 89: sqlBulk.DestinationTableName = tableName;
Line 90: sqlBulk.WriteToServer(dReader); Line 91: excelConnection.Close();
Line 92: conn.Close();

Source File: D:\pratyusha\project\pay description\pay description\upload2.aspx.cs Line: 90

Stack Trace:


[InvalidOperationException: The given ColumnMapping does not match up with any column in the source or destination.]
System.Data.SqlClient.SqlBulkCopy.AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet internalResults) +978472
System.Data.SqlClient.SqlBulkCopy.WriteToServerInternal() +1393
System.Data.SqlClient.SqlBulkCopy.WriteRowSourceToServer(Int32 columnCount) +955
System.Data.SqlClient.SqlBulkCopy.WriteToServer(IDataReader reader) +159
pay_description.upload2.ImportNow_Click(Object sender, EventArgs e) in D:\pratyusha\project\pay description\pay description\upload2.aspx.cs:90
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

manimala


Responses

Posted by: Trajuacarlos on: 10/23/2013 [Member] Starter | Points: 25

Up
0
Down
Waistband belt is not only used to tie up his trousers use at present, the international fashionable personage regard it as a kind of adornment a trend of a kind of fashion, contemporary fashionista call cool zone, is a belt of cool. Advocate environmental protection society, so to PU leather belt, the most popular leather belt less and less on the market. The current popular leather belt for gradually grew style of wide, and a wide head, a head of narrow, can reach more than 12 cm wide, with a shiny metal new decoration, color diversity, such as bright red, lake blue, Wei Zi, light yellow, white, etc. But more black, because black and any colour collocation aesthetic feeling. Because the belt has the special effect, belt became the indispensable a decorations in clothing.gobuybelts.com


Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Trajuacarlos on: 10/23/2013 [Member] Starter | Points: 25

Up
0
Down
www.gobuybelts.com Gucci Belts Outlet
www.gobuybelts.com Cheap Fendi Belts
www.gobuybelts.com Cheap gucci Belts
www.gobuybelts.com wholesale Gucci Belts
www.gobuybelts.com Cheap Louis Vuitton Belts

www.supplystarjerseys.com Cheap NFL Jerseys
www.supplystarjerseys.com NHL Jerseys Outlet


www.beltloves.com cheap Fendi Belts
www.beltloves.com Cheap Gucci Belts

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/23/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer
http://social.msdn.microsoft.com/Forums/en-US/a77f0c77-17ae-403e-bc9e-2127d003ed20/sqlbulkcopy-the-given-columnmapping-does-not-match-up-with-any-column-in-the-source-or?forum=adodotnetdataproviders

NOTE:
1) make sure your excel column names exactly match that of database table column names.
2) As the error state that , your excel columns and table (db) columns are different, before uploading the doc
please make sure,
--> no of columns in excel shold be present in table(db) if your uploading entire excel (need to mapped).

--> just recheck this, if you have TimeStamp columns in your table? Or identity columns? If you have identity columns, you need to specify SqlBulkCopyOptions.KeepIdentity


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tejamanimala on: 10/23/2013 [Member] Starter | Points: 25

Up
0
Down
ya no of columns are same and table columns and excel columns are same,still am getting this error


manimala

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/23/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Do you have Timestamp column or IDENTITY column in SQL table?

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/23/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Line 88: //Give your Destination table name 
Line 89: sqlBulk.DestinationTableName = tableName;
Line 90: sqlBulk.WriteToServer(dReader); Line 91: excelConnection.Close();
Line 92: conn.Close();


What is the name of table in the SQL Server?

sqlBulk.DestinationTableName = tableName ; -- I think you forgot to replace your table name here...


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/23/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Make sure that the column names in both are matched with respective of case ( Case sensitivity check)
http://www.adathedev.co.uk/2010/04/sqlbulkcopy-columnmappings-mismatch.html


EDIT:

using (ValidatingDataReader validator = new ValidatingDataReader(dReader, conn, sqlBulk))

{
sqlBulk.WriteToServer(validator);
}

Reference:
http://www.csvreader.com/posts/validating_datareader.php

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sally2014 on: 11/11/2014 [Member] Starter | Points: 25

Up
0
Down
cheap hermes belts http://www.micompostela.com/

cheap hermes belts http://www.micompostela.com/

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sally2014 on: 12/8/2014 [Member] Starter | Points: 25

Up
0
Down
cheap louis vuitton belts http://www.cafeasiadc.com/

cheap hermes belts http://www.micompostela.com/

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response