gpt4 book ai didi

c# - 经典 ASP 和 SQL Server Express 2005

转载 作者:太空宇宙 更新时间:2023-11-03 19:29:47 25 4
gpt4 key购买 nike

下面是我用来向 SQL Server 数据库插入一些数据的简单的 asp 代码。它给出了以下错误。有人可以看看并告诉我这段代码的错误吗?

<html>
<head>
<title>Address Book Insertion</title>
</head>
<body>
<%

set connection=Server.CreateObject("ADODB.Connection")
connection.Open "Provider=SQLOLEDB;Server=charithj-pc;Integrated Security=SSPI;Initial Catalog=AddressDB;"

cmd = "INSERT INTO AddressBook (FirstName, Surname, Address) VALUES ('"
cmd = cmd & Request("FirstName") & "','"
cmd = cmd & Request("Surname") & "','"
cmd = cmd & Request("Address") & "')"

Response.Write(cmd)

on error resume next
connection.Execute cmd
if err <> 0 then
Response.Write("Insertion failed")
else
Response.Write("Insertion successful")
end if
connection.close
%>
</body>
</html>

The website cannot display the page

HTTP 500

Most likely causes:

•The website is under maintenance.

•The website has a programming error.

最佳答案

进入您的浏览器,我假设它是 Internet Explorer 并禁用“显示友好的 http 错误”。这有助于您查看真正的错误消息。

顺便说一句。您的代码允许 sql 注入(inject)。使用sql参数或替换一些字符,如单引号等。

关于c# - 经典 ASP 和 SQL Server Express 2005,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5769653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com