Bug 9581 - Invalid formatting and other errors in SqlBulkCopy.
Summary: Invalid formatting and other errors in SqlBulkCopy.
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: master
Hardware: All Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-01-15 15:24 UTC by GenomeXP
Modified: 2017-10-21 21:51 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description GenomeXP 2013-01-15 15:24:07 UTC
There is a long standing issue with SqlBulkCopy having incorrectly formatted column names (incorrectly adding collation) and several other problems. The same mono program when run with .net libraries will run and SqlBulkCopy will copy data fine, but when executed on the mono side will error out with sql problems.

This has been tested on Linux and Windows with 2.10.9 and 3.0.2 beta. There are two aging bug reports that seem to have remained untouched other than comments, commonly the column error gets reported as "Invalid syntax near ','".
https://bugzilla.novell.com/show_bug.cgi?id=580714
https://bugzilla.novell.com/show_bug.cgi?id=519844

An example of logged queries of .NET vs MONO in the same application:

.NET:
insert bulk [CData].[dbo].[locInfo]
([ip_rngf] Float,
 [ip_rngt] Float,
 [c_code] NVarChar(2) COLLATE SQL_Latin1_General_CP1_CI_AS,
 [c_name] NVarChar(64) COLLATE SQL_Latin1_General_CP1_CI_AS,
 [region_name] NVarChar(128) COLLATE SQL_Latin1_General_CP1_CI_AS,
 [lat] Float,
 [long] Float,
 [pkey] NVarChar(10) COLLATE SQL_Latin1_General_CP1_CI_AS)
 
MONO:
 insert bulk [CData].[dbo].[locInfo]
([ip_rngf] Float(8) COLLATE ,
 [ip_rngt] Float(8) COLLATE ,
 [c_code] NVarChar(2) COLLATE SQL_Latin1_General_CP1_CI_AS,
 [c_name] NVarChar(64) COLLATE SQL_Latin1_General_CP1_CI_AS,
 [region_name] NVarChar(128) COLLATE SQL_Latin1_General_CP1_CI_AS,
 [lat] Float(8) COLLATE ,
 [long] Float(8) COLLATE ,
 [pkey] NVarChar(10) COLLATE SQL_Latin1_General_CP1_CI_AS)
Comment 1 Craig Morris 2013-10-11 15:15:35 UTC
I have done the work to fix this bug.  After fixing the reported issue, it was discovered none of the BulkCopy would work.  I downloaded the full TDS protocol spec and implemented all the needed changes.  It has been tested with almost all of the sql types and works well for our environment.  

I am now in the process of figuring out how to contribute the code changes back to the git mono repository.  I keep getting permission denied so I am now researching how I go about getting permission to contribute my changes back.
Comment 2 Craig Morris 2013-10-11 17:14:58 UTC
Pull request has been created to implement the changes in the mono base project.

https://github.com/mono/mono/pull/778
Comment 3 Alexander Köplinger [MSFT] 2017-10-21 21:51:58 UTC
Given the above pull request was merged a long time ago I'm closing this issue, thanks :)