C#清空MYSQL表的内容

时间:2013-08-29 07:21:14

标签: c# mysql

我需要从应用程序中删除一些表内容我使用MySQL命令系统但它没有空表的命令

        #region Delete
        public MySqlCommand Delete(string table, string column, string value)
        {
            _command = _command.Replace("<R>", "`" + table + "`");
            _command = _command.Replace("<C>", "`" + column + "`");
            _command = _command.Replace("<V>", "'" + value + "'");
            return this;
        }
        public MySqlCommand Delete(string table, string column, long value)
        {
            _command = _command.Replace("<R>", "`" + table + "`");
            _command = _command.Replace("<C>", "`" + column + "`");
            _command = _command.Replace("<V>", value.ToString());
            return this;
        }
        public MySqlCommand Delete(string table, string column, ulong value)
        {
            _command = _command.Replace("<R>", "`" + table + "`");
            _command = _command.Replace("<C>", "`" + column + "`");
            _command = _command.Replace("<V>", value.ToString());
            return this;
        }
        public MySqlCommand Delete(string table, string column, bool value)
        {
            _command = _command.Replace("<R>", "`" + table + "`");
            _command = _command.Replace("<C>", "`" + column + "`");
            _command = _command.Replace("<V>", (value ? "1" : "0"));
            return this;
        }

        #endregion

任何人都有任何想法清空表格,谢谢

1 个答案:

答案 0 :(得分:1)

如果您为每个要处理的mySQL命令设置使用该类,则必须添加另一种类型 ClearAll 或类似的类型:

_command = new StringBuilder("DELETE FROM <R>");

然后你必须将代码添加到其中一个执行方法中(当然)