//static private string GetConnectionString() //{ // return "Data Source=MSSQL1;Initial Catalog=AdventureWorks;" // + "Integrated Security=true;"; //} //string connectionString = GetConnectionString(); public void UcitajSveAerodrome() { using (SqlConnection conn = new SqlConnection()) { Aerodromi.Clear(); conn.ConnectionString = CONNECTION_STRING; conn.Open(); SqlCommand command = conn.CreateCommand(); command.CommandText = @"SELECT * FROM Aerodromi WHERE aktivan=1"; SqlDataAdapter daAerodromi = new SqlDataAdapter(); DataSet dsAerodromi = new DataSet(); daAerodromi.SelectCommand = command; daAerodromi.Fill(dsAerodromi, "Aerodromi"); foreach (DataRow row in dsAerodromi.Tables["Aerodromi"].Rows) { Aerodrom aerodrom = new Aerodrom(); aerodrom.Id = (int)row["Id"]; aerodrom.Sifra = (string)row["Sifra"]; aerodrom.Naziv = (string)row["Naziv"]; aerodrom.Grad = (string)row["Grad"]; aerodrom.Aktivan = (bool)row["Aktivan"]; Aerodromi.Add(aerodrom); } } }
public void UcitajAerodrome() { Aerodromi.Clear(); foreach (Aerodrom av in AerodromDAO.vratiAerodrome()) { this.Aerodromi.Add(av); } }
public void UcitajSveAerodrome() { XmlReader reader = XmlReader.Create("..//..//Data//Aerodromi.xml"); while (reader.Read()) { if (reader.NodeType.Equals(XmlNodeType.Element) && reader.Name.Equals("aerodrom")) { string sifra = reader.GetAttribute("sifra"); string naziv = reader.GetAttribute("naziv"); string grad = reader.GetAttribute("grad"); Aerodromi.Add(new Aerodrom { Sifra = sifra, Naziv = naziv, Grad = grad }); } } reader.Close(); }