Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

.net core executenonqueryasync transaction

    var sqlQuery = "delete from table";
    using (var connection = new SqlConnection(ConnectionString))
    {
        await connection.OpenAsync();
        using (var tran = connection.BeginTransaction())
        using (var command = new SqlCommand(sqlQuery, connection, tran))
        {
            try {
                await command.ExecuteNonQueryAsync();
            } catch {
                tran.Rollback();
                throw;
            }
            tran.Commit();
        }
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: wpf string to byte array 
Csharp :: google script get font color 
Csharp :: 403 forbidden error using Windows Forms 
Csharp :: c# list double min max 
Csharp :: unity number generator 
Csharp :: .Net Entity Framework Reseed SQL Server Table ID Column 
Csharp :: php check syntax error folder 
Csharp :: .net disable show exception 
Csharp :: linq contains null 
Csharp :: convert excel to datatable without xml configuration 
Csharp :: how can find github issue closed date 
Csharp :: true false when key pressed in c sharp unity 
Csharp :: go down a line in <summary dotnet 
Csharp :: using mediamanager how to play mp3 files 
Csharp :: if statement to check if a time is between two times c# 
Csharp :: web socket background.js example 
Csharp :: how to disable button until the value is selected c# 
Csharp :: c# compare 2 binary files 
Csharp :: mouse position to canvas transform 
Csharp :: tulpep notification window example c# 
Csharp :: c# convert 1 to 01 
Csharp :: use & symbole in xml as a text using c# 
Csharp :: c# linq foreach example 
Csharp :: c# printwindow chrome 
Csharp :: cqrs design pattern .net core 
Csharp :: .netstandard distinctby iqueryable 
Csharp :: add getenumerator to class c# 
Csharp :: netmath hack 
Csharp :: c# plus one 
Csharp :: how to define a static color resource in xaml wpf 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =