Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 944389 - Last Review: January 3, 2008 - Revision: 2.0
Error message when you use the SqlBulkCopy class to copy data from a resource to a data table in the .NET Framework 2.0: "System.InvalidOperationException: Failed to obtain column collation information for the destination table"
On This Page
SYMPTOMS
In a Microsoft .NET Framework 2.0 application, you use the
SqlBulkCopy class to copy data from a System.Data.DataTable to a table in Microsoft SQL Server. If the table
name contains a dot character (.),
you receive the following error message:
System.InvalidOperationException was unhandled
Message="Failed to obtain column collation information for the destination table. If the table is not in the current database the name must be qualified using the database name (e.g. [mydb]..[mytable](e.g. [mydb]..[mytable]); this also applies to temporary-tables (e.g. #mytable would be specified as tempdb..#mytable)."
Source="System.Data"
CAUSE
This problem is caused by an issue in the System.Data.dll
file.
WORKAROUND
To work around this problem, avoid
dot
characters (.)
in table names.
If you have to use a
dot character (.) in a table name,
use the dot character (.)
as part of the SQL naming convention. For example, use a table name that
resembles the
following:
server.database.schema.tablename
STATUS
Microsoft
has confirmed that this is a problem in the Microsoft products that are listed
in the "Applies to" section.
MORE INFORMATION
Steps to reproduce the behavior
- In the Northwind database, run the following SQL statement:
select * into [test.33] where 1 = 0
--Create a table named [test.33].
- Create a Visual C# application, and then run the following
code:
static void Main(string[] args)
{
SqlConnection con = new SqlConnection("Integrated Security=SSPI;Initial Catalog=Northwind;Data Source=.");
con.Open();
SqlConnection dst = new SqlConnection("Integrated Security=SSPI;Initial Catalog=Northwind;Data Source=.");
dst.Open();
SqlCommand com = new SqlCommand("select * from customers", con);
SqlDataReader dr = com.ExecuteReader();
SqlBulkCopy sbc = new SqlBulkCopy(dst);
sbc.DestinationTableName = "Northwind.dbo.[Test.33]";
sbc.WriteToServer(dr); // The failure occurs here.
dst.Close();
con.Close();
}
Call stack information
at System.Data.SqlClient.SqlBulkCopy.AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet internalResults)
at System.Data.SqlClient.SqlBulkCopy.WriteToServerInternal()
at System.Data.SqlClient.SqlBulkCopy.WriteRowSourceToServer(Int32 columnCount)
at System.Data.SqlClient.SqlBulkCopy.WriteToServer(IDataReader reader)
APPLIES TO
- Microsoft .NET Framework 2.0
- Microsoft .NET Framework 3.0
- Microsoft .NET Framework 3.5
| kbtshoot kbprb kbexpertiseadvanced KB944389 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please