Exemplo n.º 1
0
        public Straat GeefStraat(int straatId)
        {
            SqlConnection connection = GetConnection();
            string        query      = "SELECT * FROM straat WHERE id=@straatid";
            Graaf         graaf      = GeefGraaf(straatId);

            using (SqlCommand command = connection.CreateCommand())
            {
                command.CommandText = query;
                SqlParameter paramNaam = command.Parameters.Add(new SqlParameter("@straatid", SqlDbType.Int));
                command.Parameters["@straatid"].Value = straatId;
                connection.Open();
                try
                {
                    SqlDataReader reader = command.ExecuteReader();
                    reader.Read();
                    Straat straat = new Straat(straatId, (string)reader["naam"], graaf);
                    reader.Close();
                    return(straat);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    return(null);
                }
                finally
                {
                    connection.Close();
                }
            }
        }
Exemplo n.º 2
0
 public Straat(int straatId, string naam, Graaf graaf)
 {
     StraatId = straatId;
     Naam     = naam;
     Graaf    = graaf;
 }