net防止sql注入的方法:
在直接处理SQL语句时,将传递的值进行参数化,然后在进行赋值,例如:
cmd.CommandText = @"select count(*) from UserInfo where UserName=@UserName and UserPwd=@UserPwd";
cmd.Parameters.AddWithValue("@UserName",txtUserName.Text); //SQL参数化
cmd.Parameters.AddWithValue("@UserPwd",txtUserPwd.Text);
object result = cmd.ExecuteScalar();