当我尝试执行此操作时,我得到一个异常,说语法不正确?
string sql= string.Format(@"SELECT valueA
FROM tableA
WHERE columnA = @columnValueA");
var parameters = new MySqlParameter[1];
parameters[0] = new MySqlParameter("@columnValueA", string.Format("{0}","abc"));
foreach (var mySqlParameter in parameters)
{
cmd.Parameters.AddWithValue(mySqlParameter.ParameterName, mySqlParameter.Value);
}
//later I execute, it tells me the syntax is incorrect
-- I am trying to execute something on the database similar to below
SELECT valueA
FROM tableA
WHERE columnA = "abc"
答案 0 :(得分:0)
你在MySqlParameter字符串中需要@吗?我想你可以没有它吗?
答案 1 :(得分:-1)
我的查询是正确的,基本上,在代码中嵌套的内容是附加了额外的)
,这导致查询语法不正确。