Interviews - C# Corner

saumya vyas
How to delete record From DataBase through Grid View??
By saumya vyas in C# onFeb 12 2014
  • Munesh Sharma
    Apr, 2014 4

    You can use for deleting your history from database based on IDprivate void delete_btn_Click(object sender, EventArgs e) {if (!(textBox1.Text == string.Empty && textBox2.Text == string.Empty)){string str = "server = MUNESH;Database=data;UID=sa;Password=reladmin";SqlConnection con = new SqlConnection(str);string query = "Delete from registration where ID= '" + this.textBox1.Text + "' and Password = '" +this.textBox2.Text + "'";SqlCommand cmd = new SqlCommand(query, con);SqlDataReader myreader;try{con.Open();myreader = cmd.ExecuteReader();MessageBox.Show("Deleted", "user information");while (myreader.Read()){}con.Close();}catch (Exception ec){MessageBox.Show(ec.Message);}}else{MessageBox.Show("enter ID or password which you want to delete");} }

    • 0
  • Vithal Wadje
    Feb, 2014 23

    refer my article http://www.c-sharpcorner.com/UploadFile/0c1bb2/insert-update-delete-in-gridview-using-single-stored-proce/

    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS