I have a column named Status inside a datagridview, now every row has a status of 1, i want to update them to 2. Here is the code i use
private void btnCommit_Click(object sender, EventArgs e)
{
using (DataClasses2DataContext db = new DataClasses2DataContext())
{
if (MessageBox.Show("Do you want to commit it?","Yes",MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
int i = dgvDisplay.CurrentRow.Index;
ID = dgvDisplay[7, i].Value.ToString();
db.CCSDD_StatusUpdate(2, ID);
MessageBox.Show("Your Status has been updated!");
}
}
}
This works okay, however, this only updates one at a time.
Also i used a stored procedure to update a certain column
ALTER PROCEDURE [dbo].[CCSDD_StatusUpdate]
-- Add the parameters for the stored procedure here
@status int,
@id varchar(20)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
update CCSDD_StoreDirectDelivery1 set Status = @status
where DR# = @id
END
can anyone help me on how to update multiple rows?
What I have tried:
private void btnCommit_Click(object sender, EventArgs e)
{
using (DataClasses2DataContext db = new DataClasses2DataContext())
{
if (MessageBox.Show("Do you want to commit it?","Yes",MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
int i = dgvDisplay.CurrentRow.Index;
ID = dgvDisplay[7, i].Value.ToString();
db.CCSDD_StatusUpdate(2, ID);
MessageBox.Show("Your Status has been updated!");
}
}
}
.