本文介绍了.NET的MySqlCommand @占位符冲突与MySQL变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个简单的SQL,为了这个问题。 (实际的SQL是比这更复杂)
SET @HELLO = 1;
选择@HELLO;
正如你所看到的。 @HELLO
是一个MySQL变量,但.NET的MySqlCommand对待,就好像它是一个占位符不是需要绑定值。反正我有可以使用MySQL变量,.NET?
解决方案
看一看下面的 MySql.Data.MySqlClient.MySqlException:参数'@id'必须
其中规定
This is a sample SQL for the sake of this question. (The actual SQL is more complicated than this one)
SET @HELLO = 1;
SELECT @HELLO;
As you can see. @HELLO
is a MySQL variable, but .NET MySQLCommand treats as if it is a placeholder than need to bind value. Is there anyway I can use MySQL variable with .NET?
解决方案
Have a look at the following MySql.Data.MySqlClient.MySqlException: Parameter ‘@id’ must be defined
Which states
这篇关于.NET的MySqlCommand @占位符冲突与MySQL变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!