hi my dear friends,i create a project by visual studio 2012 and now im have two problem white this project:
1) when i select a row from datagreadeview and press delete button the rows are delete but not delete from database(my database is access) and my curent code for this button:
private void hazf_Click(object sender, EventArgs e)
{
if (this.dataGridView1.SelectedRows.Count > 0)
{
dataGridView1.Rows.RemoveAt(this.dataGridView1.SelectedRows[0].Index);
}
}
----------------------------------------
2) when i select a row from datagradeview and press edit button,im going into edit form and im edit the data,but when i press the save button my row is edited and saved but by a big problem,my all rows change to edited row!
private void button1_Click(object sender, EventArgs e)
{
oleDbCommand1.Parameters.Clear();
oleDbCommand1.CommandText = "UPDATE ssbm SET name=@n,family=@f,shparvande=@s,tell=@t,kolebedehi=@k,harghest=@h,aghsatemoavagh=@a,mablaghemoavagh=@m,bishtar=@b";
oleDbCommand1.Parameters.AddWithValue("@n", txtProNet1.Text);
oleDbCommand1.Parameters.AddWithValue("@f", txtProNet2.Text);
oleDbCommand1.Parameters.AddWithValue("@s", txtProNet3.Text);
oleDbCommand1.Parameters.AddWithValue("@t", txtProNet4.Text);
oleDbCommand1.Parameters.AddWithValue("@k", txtProNet5.Text);
oleDbCommand1.Parameters.AddWithValue("@h", txtProNet6.Text);
oleDbCommand1.Parameters.AddWithValue("@a", txtProNet7.Text);
oleDbCommand1.Parameters.AddWithValue("@m", txtProNet8.Text);
oleDbCommand1.Parameters.AddWithValue("@b", richTextBox1.Text);
oleDbConnection1.Open();
oleDbCommand1.ExecuteNonQuery();
oleDbConnection1.Close();
MessageBox.Show("saved!");
fedit.ActiveForm.Close();
}
----------------------------------------------