c# - ColumnMapping error with SqlBulkCopy without USE -
i have next scenario:
component a creates database d component b loads info d using sqlbulkcopyeach of a , b have it's own independent sqlconnection.
and unusual situation: used 1st step (which executed a) create database script generated sql server management studio ends statement:
utilize d go
with script works fine. however, if delete lastly statement (the use), error while executing sqlbulkcopy on b:
given columnmapping not match column in source or destination.
i'm sure b's connection points correctly on d database (i can read sqlbcp preparation statements via profiler). tried fully-qualified name datatable (db.schema.table) nil went better.
i quite confused because utilize 2 separate connections. thought not matter.
can please provide hint?
some more info: can this:
class { private sqlconnection ac; string createscript; public void dowork() { ac = new sqlconnection("connection string db x"); new sqlcommand(createscript,ac).executenonquery(); new b().dowork(); } } class b { private sqlconnection bc; public void dowork() { bc = new sqlconnection("connection string db d"); ...data table preparation here ... sqlbulkcopy bcp = new sqlbulkcopy(bc); bcp.writetoserver(dt); } }
and somewhere in main:
a.dowork();
the database d created, bc connected it. difference in use in create script.
update: i'm quite sure somewhere there deed pooling. there not shared connection strings, no 2 same connection strings present, of them have pooling=false. however, if write simple console frontend calling same same arguments in component (in case assembly in dll) b - works.
c# sqlbulkcopy use columnmappings
No comments:
Post a Comment