当前位置: 代码迷 >> 其他数据库 >> asp连接oracle9i有关问题
  详细解决方案

asp连接oracle9i有关问题

热度:4864   发布时间:2013-02-26 00:00:00.0
asp连接oracle9i问题
各位大哥大姐救命呀!!数据库大作业做到最后关键时刻元旦被卡了3天,下周要交了。我的环境是windows2003+oracle9i,ODBC的DATA SOURCE NAME:DZSW;TNS:MYSW;USER:SCOTT(建表的用户);PASSWORD:TIGER;testconntion测试时成功;但用连接代码common/conn.asp:<%
  '连接数据库
  dim conn
  dim connstr
  Set conn=Server.CreateObject("ADODB.Connection")
  connstr="Driver={Oracle in OraHome92};server=MYSW;uid=scott;pwd=tiger;"
  startime=timer()
%>
请求代码为:<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../common/conn.asp"-->
<!--#include file="../common/status"-->
<!--#include file="../common/md5.asp"--><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>管理员登录</title>
</head>
<%
dim address
address = left(cstr(request.servervariables("REMOTE_ADDR")),10)
if address<>"192.168.0." then 
%>
  您是外网用户,无权查看内部网站,五秒钟后自动返回,如果您的浏览器没有自动返回,请<a href="../admin/login">点击此处</a>。<BR>请不要重复测试,您的所作所为我们均有记录。
  <meta http-equiv="refresh" content="5;url=login">
<% else %>
<body>
  <%
dim sql,rs,admin_id,admin_pw
  admin_id=lcase(trim(request("admin_id")))
  admin_pw=lcase(trim(request("admin_pw")))
  if admin_id="" or admin_pw="" then
  errmsg=errmsg+"<br>"+"<li>管理员帐号和密码不能为空!"
  founderr=true
  else
  sql="select admin_id,admin_pw from SCOTT.ADMIN where admin_id='"&admin_id&"'"
  set rs=Server.CreateObject("ADODB.recordset")
rs.open sql,connstr
  if rs.eof then
  errmsg=errmsg+"<br>"+"<li>您输入的管理员帐号不存在!"
  founderr=true
  else if md5(admin_pw)=rs("admin_pw") then
  session("admin_id")=rs("admin_id")
session.Timeout=300
  else
  errmsg=errmsg+"<br>"+"<li>您输入的密码错误!"
  founderr=true
  end if
  end if 
  rs.close
  set rs=nothing
  end if
  if founderr=false then
response.redirect "index.asp"
else
%>
  <font><strong>错误!!!</strong></font><BR>
<%
  response.write(errmsg)
  end if
%>
<p><a href="javascript:history.go(-1)">重新登陆</a></p>
</body>
<% end if %>
</html>
出错:[Oracle][ODBC][Ora]ORA-00942: 表或视图不存在;我用SQL*PLUS查过了,ADMIN表存在并能用SELECT * FROM SCOTT.TIGER;查出ADMIN_ID,ADMIN_PS,但连接就老是报错.ODBC换为:user:system;都不行;这是为什么?
我在此先感谢各位,我的QQ是:1132077500,您可直接联系我,拜谢!!!!!

------解决方案--------------------------------------------------------
select admin_id,admin_pw from SCOTT.ADMIN where admin_id=''

很显然,你的程序有问题。你的变量admin_id根本没得到
你的程序中根本没有给这个 admin_id 赋值的语句。


这不是数据库的问题了,建议你到 asp 版去咨询一下。
  相关解决方案