• ADADADADAD

    参数化sql查询如何防止sql注入[ 网络知识 ]

    网络知识 时间:2024-12-03 15:10:09

    作者:文/会员上传

    简介:

    使用参数化查询语句进行查询的示例:string Account =Request.Form["Account"]; string sql = "select id,Name,Account from User where Account = @Account";SqlParameter[]

    以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。

    使用参数化查询语句进行查询的示例:

    string Account =Request.Form["Account"];

    string sql = "select id,Name,Account from User where Account = @Account";

    SqlParameter[] values = new SqlParameter[] { //参数化查询, 防止sql注入

    new SqlParameter("@Account",Account),

    };

    DataTable datatable = DBHelper.GetDataTable(sql, values);

    //把用户传到后台的账号Account赋值给@Account,这样数据库服务器不会将参数的内容视为SQL指令来处理,而是在数据库完成SQL指令的编译后,才套用参数运行,从而防止SQL注入。

    参数化sql查询如何防止sql注入.docx

    将本文的Word文档下载到电脑

    推荐度:

    下载
    热门标签: sql注入参数化