主题:请高手帮解决数据库连接问题
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!-- #include file="config.inc"-->
<html>
<head>
</head>
<%
if request.form("userid")=""then
response.redirect"enroll.asp"
response.End()
else
function sqlstr(data)
sqlstr="'"&replace(data,"'","''")&"'"
end function
userid=trim(request("userid"))
userpw=trim(request("userpw"))
name=trim(request("name"))
idnumber=trim(request("idnumber"))
sex=trim(request("sex"))
age=trim(request("age"))
address=trim(request("address"))
zipcode=trim(request("zipcode"))
phone=trim(request("phone"))
if phone="" then phone="没有电话"
email=trim(request("email"))
set conn=server.createobject("adodb.connection")
conn.open connstring
set rst=server.createobject("adodb.recordset")
rst.activeconnection=conn
sql="select*from users where userid="
sql=sql&sqlstr(userid)
rst.open
if not rst.eof then
response.write"已经存在此用户!"
rst.close
ersponse.end
else
response.write"<div style=""position:absolute;left:20"">"
response.write"您的资料如下<br><br><hr color=#999933 size=1>"
response.write"会员名:"&userid&"<br>"
response.write"密码:"&userpw&"<br>"
response.write"姓名:"&name&"<br>"
response.write"身份证:"&idnumber&"<br>"
response.write"性别:"&sex&"<br>"
response.write"年龄:"&age&"<br>"
response.write"地址:"&address&"<br>"
response.write"邮编:"&zipcode&"<br>"
response.write"电话:"&phone&"<br>"
response.write"E_MAIL:"&email&"<br>"
est ret1=server.createobject("adodb.recordset")
rst1.activeconnection=conn
application.lock
sql="select*from users order by custid desc"
rst1.open sql,conn,1,3
if not rst1.eof then
temp=rst1("custid")
temp=right(temp,5)
temp=cint(temp)+1
for i =1 to 5-len(temp)
temp="0"&temp
next
custid="c"&temp
else
custid="c00001"
end if
points=0
'插入一个新会员
rst1.addnew
rst1("custid")=custid
rst1("userid")=userid
rst1("userpw")=userpw
rst1("name")=name
rst1("idnumber")=idnumber
rst1("sex")=sex
rst1("age")=age
rst1("address")=adderss
rst1("zipcode")=zipcode
rst1("phone")=phone
rst1("email")=email
rst1("points")=points
rst1.update
application.unlock
response.write"<br><br>您的资料已经顺利插入了数据库,请您<a herf=""show.asp"">继续购物</a><br>"
response.write">或者您可以现在就<a herf=""oldlogin.asp"">登录</a>本网站,享受网上购物的乐趣!"
end if
end if
response.write"</div>"
%>
<body style="font:10pt"></body>
</html>
请高手们帮我看下在运行中出现在这样的问题:"
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
/购物系统/custadd.asp, 第 28 行
[color=FF0000][size=4]出现问题的地方是"conn.open connstring"
我的数据库应该没有作错.是不是代码错了?请高手们帮帮忙![/size][/color]
<!-- #include file="config.inc"-->
<html>
<head>
</head>
<%
if request.form("userid")=""then
response.redirect"enroll.asp"
response.End()
else
function sqlstr(data)
sqlstr="'"&replace(data,"'","''")&"'"
end function
userid=trim(request("userid"))
userpw=trim(request("userpw"))
name=trim(request("name"))
idnumber=trim(request("idnumber"))
sex=trim(request("sex"))
age=trim(request("age"))
address=trim(request("address"))
zipcode=trim(request("zipcode"))
phone=trim(request("phone"))
if phone="" then phone="没有电话"
email=trim(request("email"))
set conn=server.createobject("adodb.connection")
conn.open connstring
set rst=server.createobject("adodb.recordset")
rst.activeconnection=conn
sql="select*from users where userid="
sql=sql&sqlstr(userid)
rst.open
if not rst.eof then
response.write"已经存在此用户!"
rst.close
ersponse.end
else
response.write"<div style=""position:absolute;left:20"">"
response.write"您的资料如下<br><br><hr color=#999933 size=1>"
response.write"会员名:"&userid&"<br>"
response.write"密码:"&userpw&"<br>"
response.write"姓名:"&name&"<br>"
response.write"身份证:"&idnumber&"<br>"
response.write"性别:"&sex&"<br>"
response.write"年龄:"&age&"<br>"
response.write"地址:"&address&"<br>"
response.write"邮编:"&zipcode&"<br>"
response.write"电话:"&phone&"<br>"
response.write"E_MAIL:"&email&"<br>"
est ret1=server.createobject("adodb.recordset")
rst1.activeconnection=conn
application.lock
sql="select*from users order by custid desc"
rst1.open sql,conn,1,3
if not rst1.eof then
temp=rst1("custid")
temp=right(temp,5)
temp=cint(temp)+1
for i =1 to 5-len(temp)
temp="0"&temp
next
custid="c"&temp
else
custid="c00001"
end if
points=0
'插入一个新会员
rst1.addnew
rst1("custid")=custid
rst1("userid")=userid
rst1("userpw")=userpw
rst1("name")=name
rst1("idnumber")=idnumber
rst1("sex")=sex
rst1("age")=age
rst1("address")=adderss
rst1("zipcode")=zipcode
rst1("phone")=phone
rst1("email")=email
rst1("points")=points
rst1.update
application.unlock
response.write"<br><br>您的资料已经顺利插入了数据库,请您<a herf=""show.asp"">继续购物</a><br>"
response.write">或者您可以现在就<a herf=""oldlogin.asp"">登录</a>本网站,享受网上购物的乐趣!"
end if
end if
response.write"</div>"
%>
<body style="font:10pt"></body>
</html>
请高手们帮我看下在运行中出现在这样的问题:"
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
/购物系统/custadd.asp, 第 28 行
[color=FF0000][size=4]出现问题的地方是"conn.open connstring"
我的数据库应该没有作错.是不是代码错了?请高手们帮帮忙![/size][/color]