Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top