jslist
jslist

Reputation: 21

ASP.NET VB SqlBulkCopy String or binary data would be truncated

I'm trying to use SqlBulkCopy to upload a data table into SQL Server.

I'm getting this error:

String or binary data would be truncated.

I'm using

sqlBulkcopy.WriteToServer(dtCustom)

The SQL Server column is defined as nvarchar(50)

I changed the column to nvarchar(150) and same problem

This line is causing the problems with the import:

Enter the Location of Inspection

The line is 32 characters

If I remove "on" then it works and imports.

So what's the deal with a SQL Server table column defined as nvarchar(50) and 32 characters for data going into it?

Any ideas?

Upvotes: 1

Views: 452

Answers (1)

jslist
jslist

Reputation: 21

The columns have to be mapped. Even though the datatable has the same column names as the SQL table - in the asp.net vb coding you still have to do column mappings.

Upvotes: 1

Related Questions