asp本页获取表单信息写入数据库出错
<html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><formnam...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<form name=form1 method=post action="">
<title>姓名</title>
</head>
<body>
<tr>
<th width="104"align="ringht"scope="row">ID号:</th>
<td width="253"><label>
<input type="text"name="ID"/>
</label></td>
</tr>
<tr>
<th width="104"align="ringht"scope="row">
<p>姓名:</th>
<td width="253"><label>
<input type="text"name="name"/>
</label></td>
</tr>
<tr>
<th width="104"align="ringht"scope="row"></p>
<p>性别:</th>
<td width="253"><label>
<input type="text"name="sex"/>
</label></td>
</tr>
</p>
<p><input type="submit"name="submit1"value="提交"></p>
</form>
<%
Dim conn
Set conn =Server.CreateObject("ADODB.Connection")
conn.ConnectionString="driver={SQL Server};server=(LOCAL);UID=sa;PWD=;Database=text"
conn.Open
Response.Write("lian jie is ing ")
IF CONn.STATE=0 then
RESPONSE.WRITE("unsuess")
else
RESPONSE.WRITE("suess")
end if
conn.execute("insert into table1(id,name,sex)values(""&request.form("ID")&","&request.form("name")&","&request.form("sex")&)"")
Response.Write("数据已经插入到数据表中 ")
%>
</body>
</html>
================================
不知道是不是<form name=form1 method=post action="">的问题,一加上就出现“HTTP 错误 405 - 禁止访问资源 Internet 信息服务”的错误,不知是怎么回事,去掉了也没什么反应,不报错,但也不把表单里的数值提交到数据库,望高手指点迷津,谢谢了谢谢,感激不尽~~ 展开
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<form name=form1 method=post action="">
<title>姓名</title>
</head>
<body>
<tr>
<th width="104"align="ringht"scope="row">ID号:</th>
<td width="253"><label>
<input type="text"name="ID"/>
</label></td>
</tr>
<tr>
<th width="104"align="ringht"scope="row">
<p>姓名:</th>
<td width="253"><label>
<input type="text"name="name"/>
</label></td>
</tr>
<tr>
<th width="104"align="ringht"scope="row"></p>
<p>性别:</th>
<td width="253"><label>
<input type="text"name="sex"/>
</label></td>
</tr>
</p>
<p><input type="submit"name="submit1"value="提交"></p>
</form>
<%
Dim conn
Set conn =Server.CreateObject("ADODB.Connection")
conn.ConnectionString="driver={SQL Server};server=(LOCAL);UID=sa;PWD=;Database=text"
conn.Open
Response.Write("lian jie is ing ")
IF CONn.STATE=0 then
RESPONSE.WRITE("unsuess")
else
RESPONSE.WRITE("suess")
end if
conn.execute("insert into table1(id,name,sex)values(""&request.form("ID")&","&request.form("name")&","&request.form("sex")&)"")
Response.Write("数据已经插入到数据表中 ")
%>
</body>
</html>
================================
不知道是不是<form name=form1 method=post action="">的问题,一加上就出现“HTTP 错误 405 - 禁止访问资源 Internet 信息服务”的错误,不知是怎么回事,去掉了也没什么反应,不报错,但也不把表单里的数值提交到数据库,望高手指点迷津,谢谢了谢谢,感激不尽~~ 展开
1个回答
展开全部
你出错了的地方还真不少,HTML有错误,ASP有错误,Sql有错误,重新给你写了一下你看看吧
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>姓名</title>
</head>
<body>
<form name=form1 method=post action="最好在此处写本页文件名">
<table>
<tr>
<th width="104"align="ringht"scope="row">ID号:</th>
<td width="253"><input type="text"name="ID"/></td>
</tr>
<tr>
<th width="104"align="ringht"scope="row">姓名:</th>
<td width="253"><input type="text"name="name"/></td>
</tr>
<tr>
<th width="104"align="ringht"scope="row">性别:</th>
<td width="253"><input type="text"name="sex"/></td>
</tr>
<tr>
<th width="104"align="ringht"scope="row"> </th>
<td width="253"><input type="submit"name="submit1"value="提交"></td>
</tr>
</table>
</form>
<%
If Trim(Request("ID"))<>"" and Trim(Request("name"))<>"" and Trim(Request("sex"))<>"" Then
GetID=Trim(Request("ID"))
Getname=Trim(Request("name"))
Getsex=Trim(Request("sex"))
Dim conn
Set conn =Server.CreateObject("ADODB.Connection")
conn.ConnectionString="driver={SQL Server};server=(LOCAL);UID=sa;PWD=;Database=text"
conn.Open
Response.Write("lian jie is ing ")
IF Conn.STATE=0 then
RESPONSE.WRITE("unsuess")
else
RESPONSE.WRITE("suess")
end if
conn.execute("insert into table1(id,name,sex) values('"&GetID&"','"&Getname&"','"&Getsex&"')")
conn.close
set conn=nothing
Response.Write("数据已经插入到数据表中 ")
end if
%>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>姓名</title>
</head>
<body>
<form name=form1 method=post action="最好在此处写本页文件名">
<table>
<tr>
<th width="104"align="ringht"scope="row">ID号:</th>
<td width="253"><input type="text"name="ID"/></td>
</tr>
<tr>
<th width="104"align="ringht"scope="row">姓名:</th>
<td width="253"><input type="text"name="name"/></td>
</tr>
<tr>
<th width="104"align="ringht"scope="row">性别:</th>
<td width="253"><input type="text"name="sex"/></td>
</tr>
<tr>
<th width="104"align="ringht"scope="row"> </th>
<td width="253"><input type="submit"name="submit1"value="提交"></td>
</tr>
</table>
</form>
<%
If Trim(Request("ID"))<>"" and Trim(Request("name"))<>"" and Trim(Request("sex"))<>"" Then
GetID=Trim(Request("ID"))
Getname=Trim(Request("name"))
Getsex=Trim(Request("sex"))
Dim conn
Set conn =Server.CreateObject("ADODB.Connection")
conn.ConnectionString="driver={SQL Server};server=(LOCAL);UID=sa;PWD=;Database=text"
conn.Open
Response.Write("lian jie is ing ")
IF Conn.STATE=0 then
RESPONSE.WRITE("unsuess")
else
RESPONSE.WRITE("suess")
end if
conn.execute("insert into table1(id,name,sex) values('"&GetID&"','"&Getname&"','"&Getsex&"')")
conn.close
set conn=nothing
Response.Write("数据已经插入到数据表中 ")
end if
%>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询