论坛: 编程破解 标题: 一个SQL相关的数据问题~希望ASP高手能帮我解决 复制本贴地址    
作者: xly8610 [xly8610]    论坛用户   登录
页面1:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
body {
background-image:  url(img/bg.gif);
margin-top: 0px;
}
a:link {
text-decoration: none;
color: #0000FF;
}
a:visited {
text-decoration: none;
color: #0000FF;
}
a:hover {
text-decoration: none;
color: #CC3300;
}
a:active {
text-decoration: none;
}
-->
</style>
<!--#include file="css/css.css"--></head>

<body>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr bgcolor="#99CC00">
    <td width="497" height="80" bgcolor="#99CC00">&nbsp;</td>
    <td width="281" height="80">&nbsp;</td>
  </tr>
  <tr>
    <td height="297" background="img/index_left.jpg"><table width="497" height="283"  border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="29%" height="88">&nbsp;</td>
        <td width="49%">&nbsp;</td>
        <td width="22%">&nbsp;</td>
      </tr>
      <tr>
        <td height="168">&nbsp;</td>
        <td valign="top"><form name="form1" method="post" action="userlogon.asp">
          <table width="100%"  border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td colspan="2">&nbsp;</td>
              </tr>
            <tr>
              <td colspan="2">&nbsp;</td>
              </tr>
            <tr>
              <td width="24%">用户名:</td>
              <td width="76%"><INPUT name=username class="input1" id="username" size=10></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              </tr>
            <tr>
              <td>密&nbsp;&nbsp;码:</td>
              <td><INPUT name=password type="password" class="input" id="password" size=15></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td colspan="2"><div align="center">
                <input name="Enter" type="submit" class="sub" value="进入系统">
                &nbsp;&nbsp;[<a href="register.asp" class="4">注册</a>]
              </div></td>
              </tr>
          </table>
        </form></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table></td>
    <td background="img/index_right.jpg">&nbsp;</td>
  </tr>
  <tr>
    <tr>
    <td height="20" colspan="2" background="img/btm_title.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#" onClick="window.alert('欢迎使用由 凌云工作室 设计开发的办公自动化系统!\n在使用前请先阅读此帮助文件,谢谢!\n\n【权限说明】\n\n1、本系统所有功能未经管理员授权不能使用\n2、管理员可以为多人制,并且级别相同,任一合法管理员均可对管理员帐号进行添加、删除及修改操作,请管理员妥善保管各自帐号,任何原因造成的资料丢失,凌云工作室概不负责!\n\n【功能说明】\n\n1、通知发布\n2、人力资源管理\n3、网上办公系统\n4、个人助理系统\n5、电子邮件系统\n6、日常助理系统\n\n【注意事项】\n\n1、本系统采用access+asp开发,系统要求:windows9X+pws win2000(或更高)+IIS、IE 4.0以上及相关打印设备\n2、处于安全考虑,建议安装使用前,先修改数据库路径及数据库名称,然后修改链接文件相应路径设置\n3、档案输出文件为word(*.doc)格式。由于个人配置及环境不一,所以输出后建议用MS word稍作编辑\n4、系统所有查找定位均支持模糊查找。例:输入关键词:李,选择条件按 姓名 查找,则记录列表将显示所有姓名中含有 李 字的员工记录\n5、客户业务档案输出时,建议先保存后编辑,以免给你造成不必要的麻烦')" class="4">使用帮助</a>&nbsp;&nbsp;||&nbsp;&nbsp;
<a href="#" onClick="window.alert('【技术支持】\n\n#####################################################\n\n \t\t\t凌云工作室\n\t\t--------------------------------------------------------\n\t\t\tmailto:xly8610@163.com\n\n#####################################################')" class="4">技术支持</a>&nbsp;&nbsp;||&nbsp;&nbsp;
<a href="#" onClick="window.alert('【版权说明】\n\n#####################################################\n\n\t\t    本程序为凌云工作室开发完成\n\t\t  --------------------------------------------------------\n\t\t本程序版权归凌云工作室所有\n\t\t\t未经授权严禁传播和使用 \n\n#####################################################')" class="4">版权说明</a></td>
  </tr>
  </tr>
  <tr>
    <td height="200" colspan="2"><!--#include file="bq.asp"--></td>
  </tr>
</table>
</body>
</html>
页面2:
<title>办公自动化系统</title><!--#include file="includes/db.asp"-->
<%
  dim username
  dim password
  username=request("username")
  password=request("password")
  username=replaceprime(username)
  password=replaceprime(password)
  if username="" or password="" then
    call trigErr()
  end if
  sql="SELECT  Users.User_name,Users.User_pass,Users.User_id,Users_info.User_id,Users_info.Name,"
  sql=sql &"Users_info.Position_id,Dept.Dept_id,Dept.Dept_name"
  sql=sql&"FROM Users INNER JOIN Users_info INNER JOIN "
  sql=sql &"Dept ON "
  sql=sql&"Users.User_id=Users_info.User_id and Users_info.Dept_id=Dept.Dept_id "
    sql=sql&"where (Users.User_name='"&Username&"') AND (Users.User_pass='"&Password&"' AND Users_info.Fired=0)"
call openDB()
rs.open sql,conn,1,1
  if not (rs.eof)  then
      session("Position_id")=rs("Position_id")
  session("Uesr_id")=rs("User_id")
  session("Name")=rs("Name")
  session("Dept_id")=rs("Dept_id")
  session("Dept_name")=rs("Dept_name")
  session("User_name")=Username
  response.Redirect "welcome.asp"
else
  call Error()
end if
  sub Error()
  response.Write "<br><br><br>"
  response.Write "<table align='center' width='300' border='1' cellpadding='0' cellspacing='0' dordercolor='#999999'>"
  response.Write "<tr bgcolor'#999999'>"
  response.Write "<td colspan='2' height='15'>"
  response.Write "<div align='center'><font color='#FFFFFF'>操作:确认身份失败!</font></div>"
  response.write "</td>"
  response.write "</tr>"
  response.write "<tr>"
  response.write "<td colspan='2' height='23'>"
  response.write "<div align='center'><br><br>"
      response.write "用户名或密码错误!!!<br><br>"  
  response.write "<a href='javascript:onclick=history.go(-1)'>返回</a>"
  response.write "<br><br></div></td>"
  response.write "</tr></table>"
  end sub
  call closeDB()
%>
数据库文件:
<%
'定义数据库操作的各个变量
dim sql
dim rs
dim conn
'打开数据库
sub openDB()
connstr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath("mdb\office.mdb")
set conn=Server.CreateObject("ADODB.connection")
conn.open connstr
set rs=server.createobject("ADODB.Recordset")
end sub
'关闭数据库
sub closeDB()
  if isobject(conn) then
    if not (conn is Nothing) then
    set rs=nothing
conn.close
set conn=nothing
end if
end if
end sub
'身份验证
sub insureID()
  if session("user_id")="" then
      call closeDB()
  response.redirect server.mappath("\")&"index.asp"
end if
end sub
'当操作没有取得应有的权力时,显示错误信息
  sub noright()
        response.write "<div height=50 align=center valign=center>您没有进行此操作的权限,操作被取消</div>"
call closeDB()
response.end
end sub
'系统产生错误时,显示错误信息
sub trigErr()
  response.write "<div height=50 align=center valign=center>有错误发生,操作被取消.</div>"
  call closeDB()
  response.end
  end sub
  '将客户端的文本数据存入到数据库的时候不能有撇号,每次Insert和Update之前,都要先替换掉撇号
  function replacePrime(strItem)
      if strItem="" then
      call trigErr()
end if
replacePrime=replace(strItem,"'","#Rep_PRIME_lace#")
end function
'从数据库读取文本后,在发送客户端之前应该将把撇号替换回来
function replaceBack(strItem)
    if strItem="" then
  cal srigErr()
  end if
replaceBack=replace(strItem,"Rep_PRIME_lace#","'")
end function
%>

地主 发表时间: 06-04-15 17:30

回复: xly8610 [xly8610]   论坛用户   登录
它的错误提示是这样的:
错误类型:
Microsoft JET Database Engine (0x80040E14)
语法错误 (操作符丢失) 在查询表达式 'Dept.Dept_nameFROM Users INNER JOIN Users_info INNER JOIN Dept ON Users.User_id=Users_info.User_id and Users_info.Dept_id=Dept.Dept_id where (Users.User_name='admin') AND (Users.User_pass='admin' AND Users_info.Fired=0)' 中。
/off/userlogon.asp, 第 19 行
我不清楚这些,难以解决~~希望高手能帮我个忙~~在此我先谢过各位了

B1层 发表时间: 06-04-15 17:32

回复: 286 [unique]   版主   登录
前面加个“select ”

B2层 发表时间: 06-04-27 17:37

回复: xly8610 [xly8610]   论坛用户   登录
上面加了的啊

B3层 发表时间: 06-04-29 19:51

回复: NetFog [q70213526]   版主   登录
那段代码看直来冒似不错。。很久没碰书了。回家看看SQL去。哈哈



[此贴被 NetFog(q70213526) 在 04月29日22时27分 编辑过]

B4层 发表时间: 06-04-29 22:24

回复: 286 [unique]   版主   登录
sql=sql &"Users_info.Position_id,Dept.Dept_id,Dept.Dept_name"
  sql=sql&"FROM Users INNER JOIN Users_info INNER JOIN "
之间好象是少了个空格。
或是上一行尾收号前加个空格。或是下一行FROM前加个空格。

B5层 发表时间: 06-04-30 09:20

回复: zuiaizhy [zuiaizhy]   论坛用户   登录
sql=sql &"Dept ON "
这一句是不是有问题?
这是什么意思?
DEPT?  从来没见过
列名还是表名?
看你的写法应该都不是阿

B6层 发表时间: 06-06-24 05:50

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号