Zdravicko.
S SQL nacitam data do datatable takto
SqlCommand command = new SqlCommand("Select * from test WHERE DT_Start > @from and Location = @location ", backup_cnn);
command.Parameters.AddWithValue("@from", FromDate);
command.Parameters.AddWithValue("@location", Location);
SqlDataAdapter adapters = new SqlDataAdapter();
adapters.SelectCommand = command;
DataTable tables6 = new DataTable();
adapters.Fill(tables6);
dataGridView6.DataSource = tables6;
To mi funguje ako ma. Ale dajme tomu ze mi to vracia stlpec chyba kde je ciselny kod a rad by som ho zmenil takze pouzijem toto
DataTable tables6 = new DataTable();
adapters.Fill(tables6);
foreach (DataRow dr in tables6.Rows) // search whole table
{
if (dr['chyba'] == 76) // if id==2
{
dr["chyba"] = " Chyba 1"; //change the name
//break; break or not depending on you
}
}
dataGridView6.DataSource = tables6;
Problemje ze mi to upravuje len prvy vysledok a ked je viacero riadkov s rovnakym ID pre chybu upravuje len jednu.
Ako to spravit lepsie?