I'm trying to update records in a DataBase from a .csv file, using SqlBulkTools (https://github.com/tiagorosendo/SqlBulkTools)
in my web project I have <FileUpload>
and an update <Button>
, which should first browse the files from the PC and then update whatever in the .csv to the DataBase.
how to use this package in C# to be triggered when i use the update button below, also how to pickup the file from the <FileUpload>
and pass it to the button
protected void Update_btn(object sender, EventArgs e)
{
\\....
}
SQLBulkUpdate example from source:
var bulk = new BulkOperations();
books = GetBooksToUpdate();
using (TransactionScope trans = new TransactionScope())
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager
.ConnectionStrings["SqlBulkToolsTest"].ConnectionString))
{
bulk.Setup<Book>()
.ForCollection(books)
.WithTable("Books")
.AddColumn(x => x.ISBN)
.AddColumn(x => x.Title)
.AddColumn(x => x.Description)
.BulkUpdate()
.MatchTargetOn(x => x.ISBN)
.Commit(conn);
}
trans.Complete();
}