views:

242

answers:

1

Hello,

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.

Cheers

+1  A: 

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.

Abel
Thanks Abel.I'm using 5.0.77. I'll upgrade to 5.1.
G Berdal