标题: 新手求助 asp页面记录插入数据库 [打印本页] 作者: 不材之木 时间: 2010-1-11 01:45 标题: 新手求助 asp页面记录插入数据库 郁闷了好几天了,首先承认我比较菜
本人专业不是编程,而是搞网络的偏偏又接了个网站
现在是我的提交信息的页面提交不了记录进数据库 ,希望大大门帮忙
提交的代码
<!--#include file="../f/conn.asp"-->
<%
lb=request.form("xz")
gsmc=trim(request.form("gsmc"))
lxr=trim(request.form("lxr"))
dh=trim(request.form("dh"))
sj=trim(request.form("sj"))
dz=trim(request.form("dz"))
ywjs=trim(request.form("ywjs"))
ztcp=trim(request.form("ztcp"))
zy=trim(request.form("zy"))
qq=trim(request.form("qq"))
msn=trim(request.form("msn"))
email=trim(request.form("email"))
If gsmc="" or lxr=""or dh=""Or sj="" Or dz="" or email=""or ywjs=""Then
response.write "<script language=javascript>alert('星号处为必填!');history.go(-1);</script>"
response.end
Else
set rse=server.createobject("adodb.recordset")
se="select * from ["&lb&"] where gsmc='"&gsmc&"'"
rse.open se,conn,1,1
if rse.eof and rse.bof then
ins="insert into ["&lb&"](gsmc,lxr,dh,sj,dz,ywjs,ztcp,zy,qq,msn,email) values ('"&gsmc&"','"&lxr&"','"&dh&"','"&sj&"','"&dz&"','"&ywjs&"','"&ztcp&"','"&zy&"','"&qq&"','"&msn&"','"&email&"')"
conn.execute ins
Set myErrors=conn.errors
If myErrors.count=0 Then
response.write "<script language=javascript>alert('出错了!');history.go(-1);</script>"
response.End
else
response.write "<script language=javascript>alert('允许提交!');history.go(-1);</script>"
response.End
end if
else
response.write "<script language=javascript>alert('已有该公司信息!感谢您的提交!');history.go(-1);</script>"
response.end
end if
end if
rse.close
set rse=nothing
%>
conn页面的代码
<%
on error resume next
SqlDataBase = "../database/db.mdb" '数据库路径
SqlProvider = "Microsoft.Jet.OLEDB.4.0" '驱动程序[ Microsoft.Jet.OLEDB.4.0 Microsoft.ACE.OLEDB.12.0 ]
SqlPassword = "" 'ACCESS数据库密码
adConn="Provider="&SqlProvider&";Jet Oledb:Database Password="&SqlPassword&"; Data Source="&Server.MapPath("\")&""&SqlDataBase&""
set conn=server.createobject("ADODB.CONNECTION")
if err then
err.clear
else
conn.open adconn
end if
SqlNowString="now()"
if gsmc="" or lxr="" or dh="" or sj="" or dz="" or email=""or ywjs="" then
response.write "<script language=javascript>alert('星号处为必填!');history.go(-1);</script>"
response.end
end if