Link to home
Start Free TrialLog in
Avatar of TonyReba
TonyRebaFlag for United States of America

asked on

Stored Procedure to Update all tables

I have several tables on my database , each table has a Id, and a status column, I want to call a stored procedure in a click event of an asp.net button .

How would I do this?


protected void Button33_Click(object sender, EventArgs e)

    {
        using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["appdevConnectionString7"].ConnectionString))
   
       
   {
      using (SqlCommand command = new SqlCommand("sp_ClearStatus", connection))
     {
      command.CommandType = CommandType.StoredProcedure;
     //     command.Transaction.
    //   command.Parameters.AddWithValue("@Id", txName.Text.Trim());
    //   command.Parameters.AddWithValue("@Status", txtDescription.Text.Trim());
      connection.Open();
      command.ExecuteNonQuery();
    }
  }
ALTER PROCEDURE sp_ClearStatus
(
      @Id int,
      @Status nvarchar(50)
)
AS
Update NT1 set Status = 'Assigned' where  Id = @Id
Update NT2 set Status = 'Assigned' where  Id = @Id

Open in new window

SOLUTION
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TonyReba

ASKER

Found my solution