Hi, i'm filling a datagridView using DataRow and everything works fine
When i change the values on another windows Form and return to this Form ,i have a method that updates the gridView, it works fine using Datatable.Fill, but i want to use DataRow, but after update the value when execute the refresh give an error
conexion Timeout, and application crashes.
Method to Update
Can someone help me , i want to use DataRow (because i can control the returned data from database ).
Thanks
* Sorry my english i'm , portuguese.
C#:
MySqlDataReader readerNotas;
DataRow row = null;
DataTable dtNotas = new DataTable("Anota??es");
string query = "SELECT * FROM " + Controle.anotacoes;
if (estado != "")
{
query += " WHERE estado=@estado";
}
dtNotas.Rows.Clear();
this.GridNotas.DataSource = null;
cmd = new MySqlCommand(query, con.liga());
con.abre();
cmd.Parameters.AddWithValue("@estado",estado);
readerNotas = cmd.ExecuteReader();
dtNotas.Columns.Add("id");
dtNotas.Columns.Add("Nota");
while(readerNotas.Read())
{
row = dtNotas.NewRow();
row[0] = readerNotas["id"];
row[1] = readerNotas["nota"].ToString().ToUpper();
dtNotas.Rows.Add(row);
}
readerNotas.Close();
this.GridNotas.DataSource = dtNotas;
this.GridNotas.Columns[1].Visible = false;
dtNotas.AcceptChanges();
con.fecha();
}
When i change the values on another windows Form and return to this Form ,i have a method that updates the gridView, it works fine using Datatable.Fill, but i want to use DataRow, but after update the value when execute the refresh give an error
conexion Timeout, and application crashes.
Method to Update
C#:
private void Principal_Activated(object sender, EventArgs e) // Ac??es do utilizador (outros forms)
{
if (Controle.controlarUpdate == 1)
{
this.UltimasOrdens();
this.PreventivasEfectuar();
this.ReturnNotas("1");
Controle.controlarUpdate = 0;
}
}
Can someone help me , i want to use DataRow (because i can control the returned data from database ).
Thanks
* Sorry my english i'm , portuguese.
Last edited: