Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

how to use SqlBulkTools

$
0
0

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();
}

Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>