C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Errors and Solutions » General »

Cannot access destination table 'table-name' Error – During SqlBulkCopy


Posted Date: 31 Aug 2009    Resource Type: Errors and Solutions    Category: General
Author: Viji RAJKUMARMember Level: Diamond    
Rating: 1 out of 5Points: 5



Problem Description:



The above error cannot access destination table might occur when bulk copying data to Sql server table using SqlBulkCopy.



Possible Reasons:



1. If the destination table name contains spaces



2. If the destination table name contains - (hyphen) symbol



Example:







Using bulkCopy As SqlBulkCopy = _


New SqlBulkCopy(targetConnectionString, SqlBulkCopyOptions.TableLock)


bulkCopy.DestinationTableName = "abb po" '- This will Fail –Bcoz the table name contains space.


bulkCopy.DestinationTableName = "abb-po" '- This will Fail –Bcoz the table name contains space.


Try


' Write from the source to the destination.


bulkCopy.WriteToServer(OdbcDr)


Catch ex As Exception


Console.WriteLine(ex.Message)


End Try


End Using



Solution Description:



The table name should be preceded and followed by "[" and "]" respectively.





Example:



Using bulkCopy As SqlBulkCopy = _


New SqlBulkCopy(targetConnectionString, SqlBulkCopyOptions.TableLock)


bulkCopy.DestinationTableName = "[abb po]" 'Correct Code


bulkCopy.DestinationTableName = "[abb-po]" 'Correct Code


Try


' Write from the source to the destination.


bulkCopy.WriteToServer(OdbcDr)


Catch ex As Exception


Console.WriteLine(ex.Message)


End Try


End Using




For more details, visit http://vijirajkumar.blogspot.com/2009/08/cannot-access-destination-table-error.html



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Cannot access destination table 'table-name' Error – During SqlBulkCopy  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: SQL BULK COPY error: invalid attempt to call fieldcount when reader is closed Error
Previous Resource: Instructions how to Validate your non-original WINDOWS XP
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use