Exemplo n.º 1
0
        public void DeleteAlternativDB(ref Alternativ vtk)
        {
            string deleteString = @"DELETE FROM Alternativ WHERE (aaID = @aaID)";

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

                var id = (int)cmd.ExecuteNonQuery();
                vtk = null;
            }
        }
Exemplo n.º 2
0
        public void AddAlternativDB(ref Alternativ hv)
        {
            // prepare command string using paramters in string and returning the given identity

            string insertStringParam = @"INSERT INTO [Alternativ] (aatype, AdressID, PersonID)
                                                    OUTPUT INSERTED.aaID
                                                    VALUES (@aatype, @AdressID, @PersonID)";

            using (SqlCommand cmd = new SqlCommand(insertStringParam, OpenConnection))
            {
                // Get your parameters ready
                cmd.Parameters.AddWithValue("@aatype", hv.aatype);
                cmd.Parameters.AddWithValue("@AdressID", hv.Adresse.AdressID);
                cmd.Parameters.AddWithValue("@PersonID", hv.Persone.PersonID);
                hv.aaID = (long)cmd.ExecuteScalar(); //Returns the identity of the new tuple/record
            }
        }
Exemplo n.º 3
0
        public void UpdateAlternativDB(ref Alternativ vtk)
        {
            // prepare command string
            string updateString =
                @"UPDATE Alternativ                 
                        SET aatype = @aatype
                            
                        WHERE aaID = @aaID";

            using (SqlCommand cmd = new SqlCommand(updateString, OpenConnection))
            {
                // Get your parameters ready

                cmd.Parameters.AddWithValue("@aatype", vtk.aatype);


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