- Kód: Vybrat vše
SqlDataAdapter adapter = new SqlDataAdapter(com, Database.connection);
ds = new DataSet();
adapter.Fill(ds,atribut);
showTable("select * from "+table, table);
dataGridView1.DataSource = Database.ds;
dataGridView1.DataMember = table;
Snazil som sa to urobit nejak takto
- Kód: Vybrat vše
private Collection<Automechanici> Read(SqlDataReader reader)
{
Collection<Automechanici> Automechanicis = new Collection<Automechanici>();
while (reader.Read())
{
Automechanici Automechanici = new Automechanici();
Automechanici.ID_automechanika = reader.GetString(0);
Automechanici.Meno = reader.GetString(1);
Automechanici.Priezvisko = reader.GetString(3);
Automechanici.Pocet_opravenych = reader.GetString(4);
Automechanici.SPZ = reader.GetString(5);
Automechanicis.Add(Automechanici);
}
return Automechanicis;
}
private Collection<Automechanici> Select()
{
Database.Conncet();
SqlCommand command = new SqlCommand(SQL_SELECT, Database.connection);
SqlDataReader reader = command.ExecuteReader();
Collection<Automechanici> Automechanicis = Read(reader);
reader.Close();
return Automechanicis;
}
A potreboval by som to dat do toho DataGridu len neviem ako nato ..Popripade najky iny sposob toho objektovo -relacneho mapovania. Dakujem za rady.