473,517 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SqlBulkCopy.WriteToServer() blowing up on tables with Identitycolumns

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 SqlBulkCopy.WriteToServer(DataTable) - I hit the
following error "The given value of type String from the data source
cannot be converted to type bigint of the specified target column."

I tried removing the IDENTITY column from the table and it went in
fine. Most unfortunate as I really need this to work on all tables,
including those with identity cols.

Does anyone have any idea how to get around this??

thanks, dave
Jun 27 '08 #1
1 7485
On Jun 18, 12:40 pm, Dave <djohanns...@gmail.comwrote:
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 SqlBulkCopy.WriteToServer(DataTable) - I hit the
following error "The given value of type String from the data source
cannot be converted to type bigint of the specified target column."

I tried removing the IDENTITY column from the table and it went in
fine. Most unfortunate as I really need this to work on all tables,
including those with identity cols.

Does anyone have any idea how to get around this??

thanks, dave
this group doesn't get much activity so I better reply to myself. :D

when source columns don't match up exactly with destination columns,
SqlBulkCopyColumnMapping object is needed to specify mappings. I.e.
like when there are ID cols.

dave
Jun 27 '08 #2

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

Similar topics

0
1404
by: Roy | last post by:
For SqlBulkCopy class, is there a way to add columns that are not persisted when WriteToServer(DataTable) is called? I have information to be cache temperarily with the record and not need to be saved.
0
4595
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. "Transaction (Process ID 58) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction." 1) Is...
0
1298
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 catching the ProcessExit event (this is a console app). The problem is that calling WriteToServer as seen below will immediately exit the program...
1
3616
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 compatibility mode. No error when targeting SQL2000 database in 8.0 compatibility mode. Is this specific to 6.5 and is there a workaround?
3
9344
by: fingermark | last post by:
If it's possible, can someone tell me how I could ignore and log SqlBulkCopy duplicate key errors? So, if the bulkCopy.WriteToServer(dt); errors on duplicate key, I want it to log what the row items that caused the error and then to skip over this row... inserting the next.
4
5486
by: Chris | last post by:
I have created a datatable from a csv file. One of the columns is an integer which sometimes can be blank. When it is blank I add a dbnull.value to the column when I add to the datatable. This doesn't throw an error but when I do my bulk insert I get a 'data input' error. When I replace the nulls with a value it works. What am I doing wrong....
5
14755
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 exists on Server1.TableA, it should be added; if the data already exists it should be updated. I have to write a C# application do this operation on...
1
3300
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. Format("select * from {0}", TableName), connODBC) dbcmd.CommandTimeout = SQL_TIMEOUT bulkcopy.WriteToServer(dbcmd.ExecuteReader()) connODBC.Close()...
3
2301
by: SteveB | last post by:
Hi All, Using the SQLBulkCopy for big CSV files consumes almost all the memory in the computer. I found how to resolve this problem while google that, but no code was added. The person claimed that he flushed all temporary working tables every 100K records to avoid filling up the memory. If someone dealt with this please write down the...
0
7417
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7551
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5722
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5114
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
1625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
826
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
495
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.