C#清空MYSQL表内容

标签 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

谁知道清空 table ,谢谢

最佳答案

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

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

然后您必须将代码添加到Execute 方法之一(当然)

关于C#清空MYSQL表内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18504618/

相关文章:

c# - Lucene.NET 2.9 自定义过滤器添加授权

MySQL - 如何查询树?

mysql - 哪种 Ruby ORM 更好或更适合使用?

mysql - Django 选择其中字段是字符串和列值的串联

c# - 为什么 IE 不能将我的输出识别为 XML?

c# - 过程或函数 ' ' 需要未提供的参数 ' '

c# - Windows Mobile 6.5 构建时间 (VS2008)

c# - 当没有文件夹命名空间时,在 MailKit 中打开邮件文件夹

mysql - 在 MySQL 查询的 WHERE 子句中使用列别名会产生错误

php - SQL 获取查询中所有用户事件的总和