MySQL 在 C# 中以编程方式触发
我在 C# 中创建简单的 MySQL 触发器时遇到问题。 我正在使用 StringBuilder 构建以下命令字符串:
DELIMITER $
DROP TRIGGER /*!50032 IF EXISTS */ dbname
.table
$$
CREATE TRIGGER dbname
.inserttrigger
在 dbname
.table
上插入之后,
每行开始
...
结束;
$$
分隔符;
当我尝试 cmd.executeNonQuery() 时,尽管新行引用了第 1 行,但还是发生了异常(SQL 语法错误)。 - Stringbuilder 将为每个 AppendLine() 放入“\r\n”。
如果我将命令复制并粘贴到 MySQL 控制台,它就可以正常运行。
I have problem with creating a simple MySQL trigger in C#.
I'm using StringBuilder to build the following command string:
DELIMITER $$
DROP TRIGGER /*!50032 IF EXISTS */ dbname
.table
$$
CREATE TRIGGER dbname
.inserttrigger
AFTER INSERT ON dbname
.table
FOR EACH ROW BEGIN
...
END;
$$
DELIMITER ;
when I try cmd.executeNonQuery() an Exception occurs (Error in SQL syntax) which is despite the new lines referring to LINE 1. - The Stringbuilder will put in "\r\n" for every AppendLine().
If I copy and paste the command to the MySQL console it runs fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎是 MySQL 中的一个错误,带有
DELIMITER< /code> 语句,不确定它是否与您所击中的相同。已在最新版本的 MySQL 中修复。如果您使用的不是最新版本,请尝试更新 MySQL,然后重试。
This seems to have been a bug in MySQL with the
DELIMITER
statement, not sure it's the same you're hitting. Was fixed in a recent version of MySQL. If you're not using the latest version, try to update MySQL and try again.