sql参数化查询

2025-05-14 06:07:32
推荐回答(3个)
回答1:

既然选择CommandType.Text,就应该将参数替换到sql语句中,不要使用变量了。
cmd.CommandText = string.Format("select * from WSN where factor='{0}' and list='{1}'", factor, list);

回答2:

SqlCommand对象呢?

回答3:

@ list这里目测有个空格,你去掉试试?