public bool Insert(Condition data) { String sql = "insert into " + this.TableName; int i = 0; String fields = "("; String values = "("; foreach (var key in data.Keys) { fields += key; values += "'" + data[key] + "'"; if (data.Keys.Count - 1 != i) { fields += " , "; values += " , "; } i++; } fields += ")"; values += ")"; sql += fields + " value" + values; VDebug.Track(sql); this.mysqlHelper.ExecuteNonQuery(sql); return(true); }
public void Delete() { string sql = "delete from " + this.TableName + this.whereCondition; VDebug.Track(sql); this.mysqlHelper.ExecuteNonQuery(sql); }
public MysqlHelper(ConnectParam connectParam) { this.ConnectParams = connectParam; this.ConnectionString = "server=" + connectParam.Server + ";user id=" + connectParam.UserID + ";password="******";database=" + connectParam.Database; VDebug.Track(this.ConnectionString); }
public bool CheckTable(String databaseName, String tableName) { string sql = String.Format("select TABLE_NAME from information_schema.tables " + "where TABLE_NAME ='{0}' and Table_schema='{1}'", databaseName, tableName); VDebug.Track(sql); DataRow dataRow = this.ExecuteDataRow(sql); if (dataRow.Table.Rows.Count < 0) { return(false); } else { return(true); } }
public void Update(Condition data) { String sql = "update " + this.TableName + " SET "; int i = 0; foreach (var key in data.Keys) { sql += key + "='" + data[key] + "'"; if (data.Keys.Count - 1 != i) { sql += " and "; } i++; } sql += this.whereCondition; VDebug.Track(sql); this.mysqlHelper.ExecuteNonQuery(sql); }
public Table Where(Condition condition) { if (condition.Keys.Count == 0) { VDebug.Error("condition is null ,it maybe couse a error!"); } this.whereCondition = " where "; int i = 0; foreach (var key in condition.Keys) { this.whereCondition += key + "='" + condition[key] + "'"; if (condition.Keys.Count - 1 != i) { this.whereCondition += " and "; } i++; } VDebug.Track(this.whereCondition); return(this); }
private DataTable SelectExcute(String sql) { sql += this.whereCondition; VDebug.Track(sql); return(this.mysqlHelper.ExecuteDataTable(sql)); }