Bug 20563 - SqlBulkCopy does not work with varbinary
Summary: SqlBulkCopy does not work with varbinary
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: master
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-06-12 17:38 UTC by Andrew Knowles
Modified: 2017-09-01 09:30 UTC (History)
1 user (show)

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


Attachments

Description Andrew Knowles 2014-06-12 17:38:49 UTC
There are several issues with SqlBulkCopy's varbinary support:
1) BulkCopyData (TdsBulkCopy.cs) does not send the appropriate size (1 byte instead of 2 bytes)
Add:
				else if (parameter.TypeName == "varbinary")
					tds.Comm.Append ((short) size);

2) GenerateColumnMetaData (SqlBulkCopy.cs) does not generate a size clause
Add:
				} else if (sqlType == SqlDbType.VarBinary && columnSize != -1) {
					columnInfo = string.Format ("{0}({1})",
                                                sqlType,
                                                columnSize.ToString());
3) BulkCopyToServer (SqlBulkCopy.cs) does not set the size parameter (it is set to parameter.size which is 0 instead of param.size)
Change from (2 places):
										size = parameter.Size;
to (2 places):
										size = param.Size;

Note You need to log in before you can comment on or make changes to this bug.