MySQL Trigger programmatically in C#
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 Stri开发者_高级运维ngbuilder will put in "\r\n" for every AppendLine().
If I copy and paste the command to the MySQL console it runs fine.
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.
精彩评论