示例#1
0
        static void Main()
        {
            Todolist item = new Todolist("ggggg", DateTime.UtcNow, "dddd");

            PrintTask();
            Create(item);
        }
示例#2
0
        public static void Create(Todolist item)
        {
            var connString = "Host=127.0.0.1;Username=todotask_app;Password=1234;Database=todotask";

            using var conn = new NpgsqlConnection(connString);
            conn.Open();
            using (var cmd = new NpgsqlCommand("INSERT INTO task (done, title, due_date, description) VALUES (false, @title, @due_date, @description)", conn))
            {
                cmd.Parameters.AddWithValue("title", item.Title);
                cmd.Parameters.AddWithValue("due_date", item.Date);
                cmd.Parameters.AddWithValue("description", item.Description);
                cmd.ExecuteNonQuery();
            }
        }