Esempio n. 1
0
        public List <ZIPListe> GetZipListDB(ref ZIPListe zl)  //Virker ikke
        {
            string selectZIPListString = @"SELECT *
                                                FROM ZIPListe
                                                WHERE (_ZIPListeID = @_ZIPListeID)";

            using (var cmd = new SqlCommand(selectZIPListString, OpenConnection))
            {
                SqlDataReader rdr = null;
                cmd.Parameters.AddWithValue("@_ZIPListeID", zl._ZIPListeID);
                rdr = cmd.ExecuteReader();
                List <ZIPListe> zliste = new List <ZIPListe>();
                ZIPListe        zip    = null;
                while (rdr.Read())
                {
                    zip._ZIPListeID = (long)rdr["_ZIPListeID"];
                    zip._Land       = (string)rdr["_Land"];
                    zip._By         = (string)rdr["_By"];
                    zip._PostNummer = (string)rdr["_PostNummer"];
                    zliste.Add(zip);
                }

                return(zliste);
            }
        }
Esempio n. 2
0
        public void DeleteZipListeDB(ref ZIPListe zl)
        {
            string deleteString = @"DELETE FROM ZIPListe WHERE (_ZIPListeID = @_ZIPListeID)";

            using (SqlCommand cmd = new SqlCommand(deleteString, OpenConnection))
            {
                cmd.Parameters.AddWithValue("@_ZIPListeID", zl._ZIPListeID);

                var id = (long)cmd.ExecuteNonQuery();
                zl = null;
            }
        }
Esempio n. 3
0
        public void AddZIPListeDB(ref ZIPListe zl)
        {
            string insertStringParam = @"INSERT INTO [ZIPListe] (_Land, _By, _PostNummer)
                                                    OUTPUT INSERTED._ZIPListeID
                                                    VALUES (@_Land, @_By, @_PostNummer)";

            using (SqlCommand cmd = new SqlCommand(insertStringParam, OpenConnection))
            {
                cmd.Parameters.AddWithValue("@_Land", zl._Land);
                cmd.Parameters.AddWithValue("@_By", zl._By);
                cmd.Parameters.AddWithValue("@_PostNummer", zl._PostNummer);
                zl._ZIPListeID = (long)cmd.ExecuteScalar();
            }
        }
Esempio n. 4
0
        public void UpdateZipListeDB(ref ZIPListe zl)
        {
            string updateString = @"UPDATE ZIPListe
                                           SET _Land = @_Land, _By = @_By, _PostNummer = @_PostNummer
                                           WHERE _ZIPListeID = @_ZIPListeID";

            using (SqlCommand cmd = new SqlCommand(updateString, OpenConnection))
            {
                cmd.Parameters.AddWithValue("@_Land", zl._Land);
                cmd.Parameters.AddWithValue("@_By", zl._By);
                cmd.Parameters.AddWithValue("@_PostNummer", zl._PostNummer);
                cmd.Parameters.AddWithValue("@_ZIPListeID", zl._ZIPListeID);

                var id = (long)cmd.ExecuteNonQuery();
            }
        }