当前位置: 首页 > 图文教程 > 网络编程 > Javascript > ASP SQL防注入的方法

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 ASP SQL防注入的方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 446 ::
收藏到网摘: n/a

前一篇我们介绍了一种防SQL注入的终极方法,也就是最原始、最简单、最有效也是最通用的方法,就是数据类型的检查加单引号的处理,具体的内容前面一篇已经介绍过了,这里我就不重复了 下面我们将要介绍另一种在ASP里防SQL注入攻击的方法,该方法不仅仅在ASP里适用,实际上可以在任何使用ADO对象模型与数据库交互的语言中,准确的说称之为基于ADO对象模型的防SQL注入的方法或许更恰当些。好了废话不说了,来看看代码
复制代码 代码如下:

Dim conn,cmd,pra
set conn=server.createobject("adodb.connection")
conn.Open "…………" '这里省略数据库连接字
set cmd=server.createobject("adodb.Command")
set pra=server.createobject("adodb.Parameter")
cmd.ActiveConnection = conn
cmd.CommandText = "update news set title=? where id =?"
cmd.CommandType = adCmdText
Set pra = cmd.CreateParameter("title", adVarWChar, adParamInput, 50, "1'2'3")
cmd.Parameters.Append pra
Set pra = cmd.CreateParameter("id", adInteger, adParamInput, , 10)
cmd.Parameters.Append pra
cmd.Execute

news表的id字段是Integer型的,title字段是nvarchar(50)型的,执行的结果是把news表中id字段为10的记录的title字段的内容改成“1'2'3”