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");
            }
        }

Hi,

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

Regards,
Vidyadhar

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.