c# - SqlBulkCopy Insert with Identity Column -
i using sqlbulkcopy
object insert couple 1000000 generated rows database. problem table inserting has identity column. have tried setting sqlbulkcopyoptions
sqlbulkcopyoptions.keepidentity
, setting identity column 0
's, dbnull.value
, null
. none of have worked. sense missing pretty simple, if enlighten me fantastic. thanks!
edit clarify, not have identity values set in datatable
importing. want them generated part of import.
edit 2 here code utilize create base of operations sqlbulkcopy
object.
sqlbulkcopy sbc = getbulkcopy(sqlbulkcopyoptions.keepidentity); sbc.destinationtablename = lookup_table; private static sqlbulkcopy getbulkcopy(sqlbulkcopyoptions options = sqlbulkcopyoptions.default) { configuration cfg = webconfigurationmanager.openwebconfiguration("/rswifi"); string connstring = cfg.connectionstrings.connectionstrings["wifidata"].connectionstring; homecoming new sqlbulkcopy(connstring, options); }
to have destination table assign identity, not utilize sqlbulkcopyoptions.keepidentity
option. instead, don't map identity source, , don't extract source send through sqlbulkcopy
.
c# sql-server sqlbulkcopy identity-insert
No comments:
Post a Comment