Last active
May 9, 2019 15:20
-
-
Save luzemma/8dff070a77588e94142c5d21c57f741d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var query1 = "INSERT INTO tempoPerson (nombre, paterno) VALUES ('Jorge', 'Toribio');"; | |
var query2 = "INSERT INTO tempoPerson (nombre, paterno) VALUES ('David', 'Lalane');"; | |
var query3 = "INSERT INTO tempoPerson (nombre, paterno) VALUES ('Robert', 'Bloom');"; | |
using (SqlConnection connection = new SqlConnection(strConn)) | |
{ | |
connection.Open(); | |
SqlTransaction transaction = connection.BeginTransaction(); | |
try | |
{ | |
SqlCommand comm1 = new SqlCommand(query1, connection, transaction); | |
comm1.ExecuteNonQuery(); | |
SqlCommand comm2 = new SqlCommand(query2, connection, transaction); | |
comm2.ExecuteNonQuery(); | |
SqlCommand comm3 = new SqlCommand(query3, connection, transaction); | |
comm3.ExecuteNonQuery(); | |
transaction.Commit(); | |
} | |
catch (Exception ex) | |
{ | |
transaction.Rollback(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment