我想从表中删除一些记录,在C#中运行此查询是否正确,
请帮帮我
SqlCommand cmdRe = new SqlCommand("insert into msisdn_master SELECT * from tblDeactive
where msisdn in (" + str_MSISDN + ")", cn);
SqlCommand cmdRed = new SqlCommand("delete from tblDeactive where msisdn in ("+str_MSISDN+")", cn);
cmdRe.CommandType = CommandType.Text;
cmdRed.CommandType = CommandType.Text;
注意:str_MSISDN是StringBuilder,它存储插入TextField的Number。
答案 0 :(得分:3)
您应该使用正确的SQL参数。永远不要使用字符串构建,因为这会让你打开注射攻击。
阅读本教程以了解如何add parameters to SqlCommands。