在下面的代码中,用于获取特定行中的产品列表,该命令仅在我硬编码(连接)productLine
到SQL 时返回结果.参数替换永远不会发生.
+ "lineName = '@productLine' "
+ "and isVisible = 1 ";
MySqlDataAdapter adap = new MySqlDataAdapter(sql, msc);
adap.SelectCommand.Parameters.Add("@productLine", productLine);
Run Code Online (Sandbox Code Playgroud)
+ "lineName = ?productLine "
+ "and isVisible = 1 ";
MySqlDataAdapter adap = new MySqlDataAdapter(sql, msc);
adap.SelectCommand.Parameters.Add("?productLine", productLine);
Run Code Online (Sandbox Code Playgroud)