SqlBulkCopy.WriteToServer() blowing up on tables with Identitycolumns

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave

    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.Wri teToServer(Data Table) - 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
  • Dave

    #2
    Re: SqlBulkCopy.Wri teToServer() blowing up on tables with Identitycolumns

    On Jun 18, 12:40 pm, Dave <djohanns...@gm ail.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.Wri teToServer(Data Table) - 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,
    SqlBulkCopyColu mnMapping object is needed to specify mappings. I.e.
    like when there are ID cols.

    dave

    Comment

    Working...