Im relatively new to c# and im working on a project at my university, which consist in verifying a switchboard, im working in a CRUD right now to edit, create and delete items for one column in a datagridview, so here is my problem.
whenever i edit , insert or delete a row in a column, it doesn´t update the datagridview in real time, so my objective is to, when i change anything in my datagridview with the CRUD system, is has to be displayed in real time.
if anyone can help me, i appreciated it.
private void button6_Click(object sender, EventArgs e)
{
string strcon = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Verificacao de Quadros Eletricos\Verificação de Quadros Elétricos\DatabaseENG.accdb";
string comando = @"UPDATE [Norms Table] SET [Drills (according to the norm EN 61439-2)] = @drills WHERE ID=@id";
using (OleDbConnection con = new OleDbConnection(strcon))
{
using (OleDbCommand com = new OleDbCommand(comando, con))
{
com.Parameters.Add("@drills", OleDbType.VarChar).Value = textBox5.Text;
com.Parameters.Add("@id", OleDbType.VarChar).Value = textBox7.Text;
try
{
con.Open();
com.ExecuteNonQuery();
MessageBox.Show("Drill succesfully edited");
}
catch (Exception E)
{
MessageBox.Show(E.Message);
}
}
}
}
this button is for the edit, this code somehow, when i edit and right away click in a cell it updates the datagridview.
private void button5_Click(object sender, EventArgs e)
{
string strcon = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Verificacao de Quadros Eletricos\Verificação de Quadros Elétricos\DatabaseENG.accdb";
string comando = @"INSERT INTO [Norms Table]
([Drills (according to the norm EN 61439-2)])
values
(@drills)";
using (OleDbConnection con = new OleDbConnection(strcon))
{
using (OleDbCommand com = new OleDbCommand(comando, con))
{
com.Parameters.Add("@drills", OleDbType.VarChar).Value = textBox5.Text;
try
{
con.Open();
com.ExecuteNonQuery();
MessageBox.Show("Save Well Succeded !");
}
catch (Exception E)
{
MessageBox.Show(E.Message);
}
}
}
and this one is for the insert that has the problem i mentioned in the beginning.
if i explained myself poorly, im open to explain myself again, as i said, any help can be useful.