public List <string> getNotes(Guid guid, string token) { MYSql sql = new MYSql(); if (!sql.ValidToken(token)) { return(null); } MySqlConnection conn = sql.Createconnection(); conn.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conn; cmd.CommandText = "select Data from Data where Guid = @Guid;"; cmd.Parameters.AddWithValue("@Guid", guid.ToString()); MySqlDataReader dataReader = cmd.ExecuteReader(); List <string> vs = new List <string>(); while (dataReader.Read()) { vs.Add(dataReader["Data"].ToString()); } return(vs); }
public bool InsertNote(Guid guid, string token, string Data, string Title) { MYSql sql = new MYSql(); if (!sql.ValidToken(token)) { return(false); } bool test = false; MySqlConnection conn = sql.Createconnection(); try { conn.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conn; cmd.CommandText = "insert into Data(Guid, Data,Date) VALUES (@Guid,@Data,@Time);"; cmd.Parameters.AddWithValue("@guid", guid.ToString()); cmd.Parameters.AddWithValue("@Data", Data); cmd.Parameters.AddWithValue("@Time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); cmd.ExecuteNonQuery(); test = true; } catch (Exception e) { Debug.WriteLine(e); test = false; } finally { conn.Close(); } return(test); }