Loading bulk records from XML into SQL Server 2008 in ASP.NET MVC 4 -
i have requirement of loading 1000's of records xml file sql server 2008. far browsing , able code doesn't work @ all. can please me out?
i tried searching lot same not fix issue. there simple , easier understand achieve same.
here have...
public actionresult upload() { if (request.files.count > 0) { var file = request.files[0]; if (file != null && file.contentlength > 0) { try { var filename = path.getfilename(file.filename); var path = server.mappath(filename); dataset ds = new dataset(); ds.readxml(path); sqlconnection con = new sqlconnection("data source=server;initial catalog=sampleservice;user id=sa;password=123"); sqlbulkcopy sb = new sqlbulkcopy(con); sb.destinationtablename = "customer"; sb.columnmappings.add("name", "name"); sb.columnmappings.add("contactno", "contactno"); sb.columnmappings.add("address", "address"); } catch (exception ex) { var msg = ex; } } } return view(); }
can correct me if wrong somewhere? help? time.