473,379 Members | 1,184 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

DBNull with SQLBulkCopy

While using SqlBulkCopy to load data into a SQL Server 2005 database,
I've noticed an occasional exception that is saying one of the fields
in my DataTable object contains a null value and this is failing the
not null constraint on the table.

When I set up the DataTable object prior to the bulk insert I simply
set this field to an integer value, so it is never null in my code.
I've even put in some validation code on the DataTable object that runs
prior to the bulk insert and everything looks like.

This is a sporadic error and I've seen a few others that are similar so
it worries me that the objects are getting (slightly) corrupted between
the time I build them and when the bulk insert actually happens.

Has anyone seen something similar to this?

Thanks!

Dec 18 '06 #1
1 2643
You mention you set up DataTable and so then where is the code?

chanmm

"dwelzel" <dw*****@gmail.comwrote in message
news:11**********************@j72g2000cwa.googlegr oups.com...
While using SqlBulkCopy to load data into a SQL Server 2005 database,
I've noticed an occasional exception that is saying one of the fields
in my DataTable object contains a null value and this is failing the
not null constraint on the table.

When I set up the DataTable object prior to the bulk insert I simply
set this field to an integer value, so it is never null in my code.
I've even put in some validation code on the DataTable object that runs
prior to the bulk insert and everything looks like.

This is a sporadic error and I've seen a few others that are similar so
it worries me that the objects are getting (slightly) corrupted between
the time I build them and when the bulk insert actually happens.

Has anyone seen something similar to this?

Thanks!
Dec 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: tshad | last post by:
I have a value coming from my Object (or it could also be from a SqlDbReader) where I need to test for DBNull and 0. I tried to do it in one call: if (not (newPosition.ReportsTo is...
0
by: Oscar Thornell | last post by:
Hi, I am trying to enlist an instance of SqlBulkCopy into a transaction. When I executes and try to write to the database IŽll get an exception indicating a transactional deadlock. ...
0
by: Cwappy | last post by:
I have a class that builds a DataTable and then, when the process is exiting, tries to write that DataTable to SQL Server 2000 via the SqlBulkCopy class. I know the process is exiting because I'm...
1
by: harleedavidson | last post by:
Using SqlBulkCopy.WriteToServer to upload a datatable and getting: System.Data.SqlClient.SqlException Line 1: Incorrect syntax near 'COLLATE'. Database Server is SQL2000, database in in 6.5...
19
by: Dave | last post by:
If Iwant to check if dataset1.SelectQuery1.column1 == System.DBNull.Value. How do I do this? What I wrote above will give an error. -- L. A. Jones
5
by: TheSteph | last post by:
Using : MS-SQL 2005 / .NET 2.0 / VS2005 I have two server with the same database def but different data. I would like to import data from Server2.TableA to Server1.TableA. If a row doesn't...
1
by: Dave | last post by:
I'm using the SqlBulkCopy object to bulk insert large DataTable's into SQL Server. Its working well except tables with IDENTITY columns in them. When calling...
2
by: Amar | last post by:
Hi, I need to insert a large amount of records pretty frequently through my application. The quickest way to achive this seems to be SQLBulkcopy class. I have implemented the solution using the...
1
by: Sergey Zenyuk | last post by:
In VB.net windows application I use following code implementing SqlBulkCopy import: Using connODBC As New OdbcConnection(ConnStrODBC) connODBC.Open() Dim dbcmd As New OdbcCommand(String....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.