i using bulkcopy transfer excel data sql 1 of field date format have return bellow code getting error while executing please me..
sqlconnection myconnection; myconnection = new sqlconnection(connetionstring); myconnection.open(); string reportfilenpath = system.appdomain.currentdomain.basedirectory + "inputfilefortool" + "\\outsourcemanualuploadfile.xlsx"; // myconnection string excel workbook string excelconnectionstring = @"provider=microsoft.ace.oledb.12.0;data source=" + reportfilenpath + ";extended properties=excel 12.0;"; nsheetname = cbosheetname.text; nsheetname = nsheetname.replace("$", ""); // create myconnection excel workbook using (oledbconnection newconnection = new oledbconnection(excelconnectionstring)) { oledbcommand command = new oledbcommand ("select * [" + nsheetname + "$]", newconnection); newconnection.open(); oledbdatareader dr = command.executereader(); // bulk copy sql server //sqlbulkcopy bulkcopy = new sqlbulkcopy(connetionstring,sqlbulkcopyoptions.keepidentity); using (sqlbulkcopy bc = new sqlbulkcopy(connetionstring, sqlbulkcopyoptions.keepidentity)) //using (sqlbulkcopy bc = new sqlbulkcopy(connetionstring)) { bc.columnmappings.clear(); bc.destinationtablename = "outsourcemanualupload"; bc.columnmappings.add("device", "device"); bc.columnmappings.add("brand", "brand"); bc.columnmappings.add("model", "model"); bc.columnmappings.add("region", "region"); bc.columnmappings.add("date", "date")); bc.columnmappings.add("resource", "resource"); bc.writetoserver(dr); } newconnection.close(); } myconnection.close(); }
Comments
Post a Comment