Beispiel #1
0
        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);
        }
Beispiel #2
0
        public void Delete()
        {
            string sql = "delete from " + this.TableName + this.whereCondition;

            VDebug.Track(sql);
            this.mysqlHelper.ExecuteNonQuery(sql);
        }
Beispiel #3
0
 public MysqlHelper(ConnectParam connectParam)
 {
     this.ConnectParams    = connectParam;
     this.ConnectionString = "server=" + connectParam.Server +
                             ";user id=" + connectParam.UserID +
                             ";password="******";database=" + connectParam.Database;
     VDebug.Track(this.ConnectionString);
 }
Beispiel #4
0
        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);
            }
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
 private DataTable SelectExcute(String sql)
 {
     sql += this.whereCondition;
     VDebug.Track(sql);
     return(this.mysqlHelper.ExecuteDataTable(sql));
 }