I have a C# function and SQL server stored procedure its delete row in my gridview. How can I make it delete multiple selected rows ?
C# function:
public void DeleteReciver(int Reciver_number)
{
DAL.DataAccessLayer DAL = new DAL.DataAccessLayer();
DAL.Open();
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@Reciver_number", SqlDbType.Int);
param[0].Value = Reciver_number;
DAL.excutecommand("DeleteReciver", param);
DAL.close();
}
SQLSERVER stored procedure:
create proc DeleteReciver
@Reciver_number int
as
delete from Recivers where Reciver_number=@Reciver_number
using
if (MessageBox.Show("Are you sure you want delete this reciver? ", "delete row", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
REC.DeleteReciver(Convert.ToInt32(this.dataGridView1.CurrentRow.Cells[2].Value));
MessageBox.Show("Reciver deleted successfully", "delete row", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.dataGridView1.DataSource = REC.GET_ALL_RECIVERS();
}
else
{
MessageBox.Show("cancelled", "delete row", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}