narasiman rao

narasiman rao

  • NA
  • 519
  • 765.8k

How to write the delete query in sqlserver

Oct 12 2012 5:58 AM
i have created one design for that i done insert command,successfully all the datas are stored in the datasbase. i want to write the delete query how to do?

Design as follows;

Employeed id  textbox1

Name              textbox2

DOB                textbox3

Age                 textbox4

Address           textbox5

Area                textbox6

Mobile             textbox7

Insert Code as follows;

con = new SqlConnection("Server=(local);initial catalog=master;Trusted_Connection=True");
        con.Open();
        SqlCommand cmd = new SqlCommand("Employee", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@EmployeeID", DropDownList1.SelectedValue));
        cmd.Parameters.Add(new SqlParameter("@EmployeeName", TextBox1.Text));
        cmd.Parameters.Add(new SqlParameter("@DOB", TextBox2.Text));
        cmd.Parameters.Add(new SqlParameter("@Age", TextBox3.Text));
        cmd.Parameters.Add(new SqlParameter("@Address", TextBox4.Text));
        cmd.Parameters.Add(new SqlParameter("@Area", TextBox5.Text));
        cmd.Parameters.Add(new SqlParameter("@Mobile", TextBox6.Text));
        cmd.Parameters.Add(new SqlParameter("@Phone", TextBox8.Text));
        cmd.ExecuteNonQuery();
        SqlCommand cmd1 = new SqlCommand("select * from Empdet", con);
        SqlDataAdapter adp = new SqlDataAdapter(cmd1);
        DataSet ds = new DataSet();
        adp.Fill(ds);
        con.Close();
        GridView1.DataSource = ds;
        GridView1.DataBind();

        DetailsView1.DataSource = ds;
        DetailsView1.DataBind();   


how to write the delete query please help me.

Regards,

Rao.,


Answers (1)