Beispiel #1
0
        internal NoteClass MakeNote(IDataRecord reader)
        {
            int       id      = reader.GetInt32(0);
            string    titel   = reader.GetString(1);
            string    note    = reader.GetString(2);
            NoteClass tmpNote = new NoteClass(id, titel, note);

            return(tmpNote);
        }
Beispiel #2
0
        public void UpdateNote(NoteClass noteClass)
        {
            const string updateOpskrift = "Update Noter Set Titel=@Titel,Note=@Note where Id=@id";

            using (SqlConnection dataConnection = new SqlConnection(ConnectionString))
            {
                dataConnection.Open();
                using (SqlCommand updateCommand = new SqlCommand(updateOpskrift, dataConnection))
                {
                    updateCommand.Parameters.AddWithValue("@id", noteClass.Id);
                    updateCommand.Parameters.AddWithValue("@Titel", noteClass.Titel);
                    updateCommand.Parameters.AddWithValue("@Note", noteClass.Note);
                    updateCommand.ExecuteNonQuery();
                }
            }
        }
Beispiel #3
0
        public int PostNote(NoteClass noteClass)
        {
            const string insertNote = "insert into Noter (Titel, Note) values (@Titel, @Note)";

            using (SqlConnection dataConnection = new SqlConnection(ConnectionString))
            {
                dataConnection.Open();
                using (SqlCommand insertCommand = new SqlCommand(insertNote, dataConnection))
                {
                    insertCommand.Parameters.AddWithValue("@Titel", noteClass.Titel);
                    insertCommand.Parameters.AddWithValue("@Note", noteClass.Note);
                    int inters = insertCommand.ExecuteNonQuery();
                    if (inters != 0)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
        }