public void RemoveRow(object obj) { string Query = String.Format("DELETE FROM `{0}` where {1}=\'{2}\'", Name, "UID", datatype.GetField("UID").GetValue(obj).ToString()); Core2.ExecuteNonQuery(Query); data.Remove(obj); }
public dynamic AddRow(object obj) { string Query = string.Format("INSERT INTO `{0}`(", Name); List <String> _values = new List <string>(); List <String> _schema = new List <string>(); System.Reflection.FieldInfo[] fields = obj.GetType().GetFields(); foreach (System.Reflection.FieldInfo i in fields) { _schema.Add(String.Format(" `{0}`", i.Name.ToString())); _values.Add(QueryFieldTypeConverter(i.FieldType, i.GetValue(obj))); } Query = Query + String.Join(",", _schema); Query = Query + ") VALUES ( "; Query = Query + String.Join(",", _values); Query = Query + ")"; int QueryResult = Core2.ExecuteNonQuery(Query); if (QueryResult == -1) { throw new Exception("SQL Error Unable to execute AddRow Invalid Data. " + Query); } try { (obj as item).Parent = this; } catch { } return(obj); }
public void CreateTable() { // Creates Table if not exists string Query = string.Format("CREATE TABLE IF NOT EXISTS `{0}` (", Name); List <String> TableData = new List <string>(); foreach (Tuple <string, string> i in schema) { TableData.Add(string.Format(" `{0}` {1}", i.Item1, i.Item2)); } Query = Query + String.Join(",", TableData) + " )"; Core2.ExecuteNonQuery(Query); }