C# with MySQL INSERT parameters

后端 未结 9 1974
-上瘾入骨i
-上瘾入骨i 2020-11-28 10:47

Good day to all, I\'m using Visual C# 2010 and MySQL Version 5.1.48-community. I hope you can help me with this code. I don\'t find it working on me. What am I missing?

9条回答
  •  青春惊慌失措
    2020-11-28 11:44

    I had the same issue -- Finally tried the ? sigil instead of @, and it worked.

    According to the docs:

    Note. Prior versions of the provider used the '@' symbol to mark parameters in SQL. This is incompatible with MySQL user variables, so the provider now uses the '?' symbol to locate parameters in SQL. To support older code, you can set 'old syntax=yes' on your connection string. If you do this, please be aware that an exception will not be throw if you fail to define a parameter that you intended to use in your SQL.

    Really? Why don't you just throw an exception if someone tries to use the so called old syntax? A few hours down the drain for a 20 line program...

    MySQL::MySQLCommand

提交回复
热议问题