I am trying to update select rows of the datagrid/sql table with textbox values entered in by the user. The can be updated with the code below but the value entered into the first textbox, textBox1, is entered into every row/column. Imgur album for datagridview post update :
private void button2_Click(object sender, EventArgs e)
{
SqlConnection connectiont = new SqlConnection("Data Source=DESKTOP-P3JSE1C;Initial Catalog=logins;Integrated Security=True");
{
connectiont.Open();
SqlCommand update = new SqlCommand("UPDATE dbo.logins SET site = @site, username = @username, pword = @pword, email = @email", connectiont);
update.Parameters.AddWithValue("@site", textBox1.Text);
update.Parameters.AddWithValue("@username", textBox1.Text);
update.Parameters.AddWithValue("@pword", textBox1.Text);
update.Parameters.AddWithValue("@email", textBox1.Text);
update.ExecuteNonQuery();
}
clear();//method to clear textboxes on the form w/ datagridview
}
