String s1 = "select count(*) from user where id=@i ";
using (SQLCommand command= new SQLCommand(s1, conn)) {
command.Parameters.Add(new SqlParameter[color=red]("id",1));[/color]}
在sql中,new SqlParameter("id",1)第一个参数id是不用@符号的;
而在mysql中,则需要@
using (MySQLCommand cmd2 = new MySQLCommand(s1, conn)) {
cmd2.Parameters.Add(new MySQLParameter[color=red]("@i",1));[/color]}
using (SQLCommand command= new SQLCommand(s1, conn)) {
command.Parameters.Add(new SqlParameter[color=red]("id",1));[/color]}
在sql中,new SqlParameter("id",1)第一个参数id是不用@符号的;
而在mysql中,则需要@
using (MySQLCommand cmd2 = new MySQLCommand(s1, conn)) {
cmd2.Parameters.Add(new MySQLParameter[color=red]("@i",1));[/color]}
本文详细对比了在SQL中使用newSqlParameter与在MySQL中使用MySQLParameter进行参数化的不同,包括参数名称的语法差异及应用场景。
706

被折叠的 条评论
为什么被折叠?



