We help IT Professionals succeed at work.

Stored Procedure to Update all tables

Medium Priority
203 Views
Last Modified: 2012-05-11
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

Comment
Watch Question

CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Found my solution
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.