M
minboy
Unregistered / Unconfirmed
GUEST, unregistred user!
请教ASP简单的问题,我的save.ASP为什么不能把数据保存到数据库里面那!
下面是两个页面的代码!
conn.asp
<%@LANGUAGE="VBSCRIPT"
CODEPAGE="936"%>
<%
'option explicit
dim dataname,starttime,conn,db
response.buffer=true
starttime=timer()*1000
%>
<%
Dim connstr
db="../jtsc.mdb"
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
& Server.MapPath(db)
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection"
conn.Open connstr
If Err then
err.Clear
Set Conn = Nothing
Response.Write "Sorry! 数据库连接出错,请检查连接字串。"
Response.End
End If
%>
________________________________________________________________________________
Add_zj_gzl_save.asp
<!--#include file="conn.asp"-->
<LINK href="../main.css"
type=text/css rel=stylesheet>
<%Administer="01"%>
<!--#include file="check.asp"
-->
<style>
<!--
.button {
background-image:url(images/bbk.gif);
background-color:#ffffff;
height=20;
font-size:12px;
border:#666666 1px solid
}
-->
</style>
<!--#include file="Message.asp"
-->
<%if request("year"=""
then
%>
<script language=javascript>
alert( "错误:请选择年份!"
);
location.href = "javascript:history.back()"
</script>
<%response.end
end if%>
<%if request("month"=""
then
%>
<script language=javascript>
alert( "错误:请选择月份”!"
);
location.href = "javascript:history.back()"
</script>
<%response.end
end if%>
<%if request("day"=""
then
%>
<script language=javascript>
alert( "错误:请选择日期!"
);
location.href = "javascript:history.back()"
</script>
<%response.end
end if%>
<%
message=""
years=Request.Form("year"
if len(Request.Form("month")=1 then
months="0"&Request.Form("month"
else
months=Request.Form("month"
end if
if len(Request.Form("day")=1 then
days="0"&Request.Form("day"
else
days=Request.Form("day"
end if
set rs=server.createobject("adodb.recordset"
sql="select * from SCXX_ZJ_GZL"
rs.open sql,conn,1,3
rs.addnew
rs("tjrq"=years&"-"&months&"-"&days
rs("rjc"=trim(request.Form("rjc")
rs("ylj"=trim(request.Form("ylj")
rs("ylh"=trim(request.Form("ylh")
rs("bfb"=trim(request.Form("bfb")
rs("nlj"=trim(request.Form("nlj")
rs("nkjs"=trim(request.Form("nkjs")
rs("nwjs"=trim(request.Form("nwjs")
rs("nzqgc"=trim(request.Form("nzqgc")
rs("njdbq"=trim(request.Form("njdbq")
rs("dyzj"=trim(request.Form("dyzj")
rs("zc"=trim(request.Form("zc")
rs("wj"=trim(request.Form("wj")
rs("bq"=trim(request.Form("bq")
rs("az"=trim(request.Form("az")
rs("jx"=trim(request.Form("jx")
rs("zt"=trim(request.Form("zt")
rs("fz"=trim(request.Form("fz")
rs("sg"=trim(request.Form("sg")
rs("zx"=trim(request.Form("zx")
rs("qt"=trim(request.Form("qt")
rs("dc"=trim(request.Form("dc")
rs("gj"=trim(request.Form("gj")
rs("other"=trim(request.Form("other")
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<head></head>
<div align="center">
<center>
<table border="1"
width="450"
cellspacing="0"
cellpadding="3"
bordercolorlight="#FFCC00"
bordercolor="#FFCC00">
<tr>
<td width="100%"
bgcolor="#FFCC00">提示信息>>><font color=red><b>Succeed!添加信息成功!</b></font></td>
</tr>
<tr>
<td width="100%">
<table border="1"
width="100%"
cellspacing="0"
cellpadding="2"
bordercolorlight="#000000"
bordercolordark="#FFFFFF"
bordercolor="#000000">
<tr>
<td width="100%"
align="center"
colspan="2"><font color=red><b>Succeed!添加信息成功!您向数据库中添加的如下信息已经成功保存...</b></font></td>
</tr>
<tr>
<td width="100%"
align="center"
colspan="2">
<input type=button class="button"
name="Submit"
value="继续添加"
onClick="location.href='Add_zj_GZL.asp'"></td>
</tr>
</center>
</table>
</td>
</tr>
<center>
<tr>
<td width="100%"
bgcolor="#FFCC00">
<p align="center">版权所有:青海石油管理局钻井公司
技术支持电话:8911367</p>
</td>
</tr>
</table>
</center>
</div>
下面是两个页面的代码!
conn.asp
<%@LANGUAGE="VBSCRIPT"
CODEPAGE="936"%>
<%
'option explicit
dim dataname,starttime,conn,db
response.buffer=true
starttime=timer()*1000
%>
<%
Dim connstr
db="../jtsc.mdb"
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
& Server.MapPath(db)
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection"
conn.Open connstr
If Err then
err.Clear
Set Conn = Nothing
Response.Write "Sorry! 数据库连接出错,请检查连接字串。"
Response.End
End If
%>
________________________________________________________________________________
Add_zj_gzl_save.asp
<!--#include file="conn.asp"-->
<LINK href="../main.css"
type=text/css rel=stylesheet>
<%Administer="01"%>
<!--#include file="check.asp"
-->
<style>
<!--
.button {
background-image:url(images/bbk.gif);
background-color:#ffffff;
height=20;
font-size:12px;
border:#666666 1px solid
}
-->
</style>
<!--#include file="Message.asp"
-->
<%if request("year"=""
then
%>
<script language=javascript>
alert( "错误:请选择年份!"
);
location.href = "javascript:history.back()"
</script>
<%response.end
end if%>
<%if request("month"=""
then
%>
<script language=javascript>
alert( "错误:请选择月份”!"
);
location.href = "javascript:history.back()"
</script>
<%response.end
end if%>
<%if request("day"=""
then
%>
<script language=javascript>
alert( "错误:请选择日期!"
);
location.href = "javascript:history.back()"
</script>
<%response.end
end if%>
<%
message=""
years=Request.Form("year"
if len(Request.Form("month")=1 then
months="0"&Request.Form("month"
else
months=Request.Form("month"
end if
if len(Request.Form("day")=1 then
days="0"&Request.Form("day"
else
days=Request.Form("day"
end if
set rs=server.createobject("adodb.recordset"
sql="select * from SCXX_ZJ_GZL"
rs.open sql,conn,1,3
rs.addnew
rs("tjrq"=years&"-"&months&"-"&days
rs("rjc"=trim(request.Form("rjc")
rs("ylj"=trim(request.Form("ylj")
rs("ylh"=trim(request.Form("ylh")
rs("bfb"=trim(request.Form("bfb")
rs("nlj"=trim(request.Form("nlj")
rs("nkjs"=trim(request.Form("nkjs")
rs("nwjs"=trim(request.Form("nwjs")
rs("nzqgc"=trim(request.Form("nzqgc")
rs("njdbq"=trim(request.Form("njdbq")
rs("dyzj"=trim(request.Form("dyzj")
rs("zc"=trim(request.Form("zc")
rs("wj"=trim(request.Form("wj")
rs("bq"=trim(request.Form("bq")
rs("az"=trim(request.Form("az")
rs("jx"=trim(request.Form("jx")
rs("zt"=trim(request.Form("zt")
rs("fz"=trim(request.Form("fz")
rs("sg"=trim(request.Form("sg")
rs("zx"=trim(request.Form("zx")
rs("qt"=trim(request.Form("qt")
rs("dc"=trim(request.Form("dc")
rs("gj"=trim(request.Form("gj")
rs("other"=trim(request.Form("other")
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<head></head>
<div align="center">
<center>
<table border="1"
width="450"
cellspacing="0"
cellpadding="3"
bordercolorlight="#FFCC00"
bordercolor="#FFCC00">
<tr>
<td width="100%"
bgcolor="#FFCC00">提示信息>>><font color=red><b>Succeed!添加信息成功!</b></font></td>
</tr>
<tr>
<td width="100%">
<table border="1"
width="100%"
cellspacing="0"
cellpadding="2"
bordercolorlight="#000000"
bordercolordark="#FFFFFF"
bordercolor="#000000">
<tr>
<td width="100%"
align="center"
colspan="2"><font color=red><b>Succeed!添加信息成功!您向数据库中添加的如下信息已经成功保存...</b></font></td>
</tr>
<tr>
<td width="100%"
align="center"
colspan="2">
<input type=button class="button"
name="Submit"
value="继续添加"
onClick="location.href='Add_zj_GZL.asp'"></td>
</tr>
</center>
</table>
</td>
</tr>
<center>
<tr>
<td width="100%"
bgcolor="#FFCC00">
<p align="center">版权所有:青海石油管理局钻井公司
技术支持电话:8911367</p>
</td>
</tr>
</table>
</center>
</div>