on 08-27-2018 7:51 AM
My source has 2 columns (Viz: ForeName and SurName) and Destination has 3 columns out of which one is identity column (viz Id(smallint identity), Forename and Surname ).
The Mapping for Id column is null (i.e. no mapping is done)
using (AseBulkCopy blk = new AseBulkCopy(connectionString))
{ //set the timeout as the default is 30s
blk.BulkCopyTimeout = 30;
blk.DestinationTableName = "Employee";
blk.ColumnMappings.Clear();
//Mapping Source and target ordinals
blk.ColumnMappings.Add(new AseBulkCopyColumnMapping(0,1));
blk.ColumnMappings.Add(new AseBulkCopyColumnMapping(1,2));
blk.WriteToServer(dataSource);
blk.Close();
}
AseBulkCopy.WriteToServer(dataSource) Throws an exception Sybase.Data.AseClient.AseException: Bulk insert failed. Null value is not allowed in not null column.
This is from DBA perspective more familiarity with ASE utility bcp -
bcp - in has two options to handle identity columns while loading data.
-E to take data from input file. So identity column must be included in the data
-g <Identity start value> - Idenity column not included in the data
In the C# code do you have any setting to simulate the second option above and give it a start value of 1 or whatever suits your requirement.?
HTH
Avinash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I remember this exact problem years ago. This was CR 678477 Using EnableBulkLoad=0 with identity column results in error. This was fixed in 15.7 ESD#5 and higher.
Are you adding enablebulkload=1 to your connection string?
I also remember an issue with identity column that was corrupted that caused this same issue, the identity value was changed and the ASE didn't map the change correctly, some ASE bug if I remember right.
Thanks,
Dawn Kim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.