public MessageCollection() { Content = new List<WebMessage>(); DatabaseConnector dbc = new DatabaseConnector(); var result = dbc.send("select * from Messages"); foreach(String[] s in result) { Content.Add(new WebMessage { DateSent = DateTime.Parse(s[0]), Message = s[1] }); } }
static void Main(string[] args) { Console.Write("Enter message to post (or /c to cancel): "); String SQLInput = Console.ReadLine(); if (SQLInput.ToLower() != "/c") { //Create new connection to database DatabaseConnector dbc = new DatabaseConnector(); //Send request to database var sending = dbc.send("INSERT INTO Messages (Message) VALUES ('" + SQLInput + "');"); Console.WriteLine("Message sent: " + SQLInput); Console.ReadKey(); //INSERT INTO Messages (Message) VALUES ('HELLO') } }