0

hiiiiiiiii evryone,
plz help me out.i want to delete a record but not able to do so.plz check the code and rectify the mistake.it is giving some unknown error.thnqqq

private void button1_Click(object sender, EventArgs e)
        {
            int i;
           
          String  sqlvar =("Delete from emp where empno=" + textBox1.text);

          string conn1 = "Data Source=(local);" +
  "Initial Catalog=master;" +
  "Integrated Security=SSPI";
            SqlConnection cn=new SqlConnection(conn1);
            cn.Open();
         
            SqlCommand cmd = new SqlCommand(sqlvar,cn );
            i = cmd.ExecuteNonQuery();
            if (i > 0)
            {
                MessageBox.Show("cmd executed");
            }
            else
            {
                MessageBox.Show("not executed");
            }
        }
4
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by JerryShaw
0

Hi,

Can you write back exact error message u get... with full description..

Regards,
Vidyadhar

0

Make sure your catalog is set to the correct database. Currently it is set to master which is the primary system database.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.