Author: shirish_padekar | Posted on: 1/8/2009 9:49:44 PM | Views : 423


I am using 25 sqlDataSource controls on a single form and at a time their insert is called on button click.
Each sqlDataSource is having corresponding stored procedure.
What I want is that if any of the  SqlDataSource throws error while inserting then all previous insert done should be cancelled.

1. If I use sqlCommand object insted of sqlDataSource then this can be done by using following code:
 
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            connection.Open();
            transaction = connection.BeginTransaction();

            SqlCommand1.ExecuteNonQuery();
  ...

Go to the complete details ...