国内vps的sql中in的参数怎么注入

已关闭留言


国内vps的
sql

in
的参数注入示例:

where in的每一个参数生成一个参数,代码如下:

using (SqlConnection conn = new SqlConnection(connectionString))

{

conn.Open();

SqlCommand comm = new SqlCommand();

comm.Connection = conn;

//为每一条数据添加一个参数

comm.CommandText = “select * from Users(nolock) where UserID in (@UserID1,@UserId2,@UserID3,@UserID4)”;

comm.Parameters.AddRange(

new SqlParameter[]{

new SqlParameter(“@UserID1”, SqlDbType.Int) { Value = 1},

new SqlParameter(“@UserID2”, SqlDbType.Int) { Value = 2},

new SqlParameter(“@UserID3”, SqlDbType.Int) { Value = 3},

new SqlParameter(“@UserID4”, SqlDbType.Int) { Value = 4}

});

comm.ExecuteNonQuery();

}