Home > Web Front-end > JS Tutorial > body text

ASP SQL防注入的方法_jquery

WBOY
Release: 2016-05-16 18:57:12
Original
1366 people have browsed it

下面我们将要介绍另一种在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”
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!