zoukankan      html  css  js  c++  java
  • 在ASP页面进行参数化 使用access数据库

    今天学校让解决一个sql注入的问题,提出的需求是进行参数化。然后在网上找了好多代码都不行,有一篇对我的帮助很大

    链接:在ASP页面进行参数化查新一例

    然后我们本来的代码是这样的

    <% id=trim(request("id"))
    exec2="select * from news where id="&id	
    set rs=server.createobject("adodb.recordset")
    rs.open exec2,conn,1,1				
    %>
    

      按照博客里面说的也会出现问题,我最后改成了这样的格式就没有问题了。

    Dim rs, cmd, cn
    Set cmd = Server.CreateObject( "ADODB.Command" )
    With cmd
        .ActiveConnection = conn
        .CommandText = "select * from news where id=?" 
        .Prepared = True 
        .Parameters( 0 ).Value =id
         Set rs = .Execute
    End With 
    

      希望对大家有所帮助

    一定要把commendType删了,不然不行的啊

  • 相关阅读:
    HDU 4005 The war
    #undef
    [转载] #define new DEBUG_NEW
    [转载]常用正则表达式
    [百科]
    [转载]
    [转载]
    [转载]
    [百科]
    [转载]VC6中的文件后缀
  • 原文地址:https://www.cnblogs.com/Gabby/p/5422886.html
Copyright © 2011-2022 走看看