按钮启用禁用Sqlserver触发按钮单击

时间:2017-10-11 17:27:21

标签: c# sql-server

是否可以在按钮单击

上启用或禁用C#中的sqlserver触发器
private void button1_Click(object sender, EventArgs e)
        {
           try
                {
                    string connectionString = @"Data Source=ABC-SERVER;Initial Catalog=TESTCO;Persist Security Info=True;User ID=sa;Password=password";
                    using (SqlConnection conn =
                        new SqlConnection(connectionString))
                    {
                        conn.Open();
                        using (SqlCommand cmd =new SqlCommand("DISABLE TRIGGER [dbo].[MSETUP] ON [dbo].[parts] ", conn))
                        {
                             int rows = cmd.ExecuteNonQuery();

                        }
                    }
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);

                }
          }

如何从C#或任何建议中获取此功能?

0 个答案:

没有答案