Thursday, 16 February 2012

Delete Record on delete button in sql server with C#.net


private void BtnDelete_Click(object sender, EventArgs e)
        {
            string str2 = string.Empty;
         
                try
                {
                    str2 = "delete from Registration where SNO='" + TxtSno.Text + "'";
                    con.Open();
                    SqlCommand cmd = new SqlCommand(str2, con);
                    cmd.ExecuteScalar();
                    TxtAge.Text = TxtDob.Text = TxtGender.Text = TxtName.Text = TxtSno.Text = "";

                }
               
            catch (Exception ex2)
            {
                MessageBox.Show(ex2.Message);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }

            }
        }
       

No comments:

Post a Comment