| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 775 人关注过本帖
标题:为什么这个语句不能连接到数据库?
只看楼主 加入收藏
卜酷塔
Rank: 7Rank: 7Rank: 7
来 自:魅力青岛
等 级:禁止访问
威 望:39
帖 子:2569
专家分:0
注 册:2004-6-12
收藏
 问题点数:0 回复次数:7 
为什么这个语句不能连接到数据库?

<%OPTION EXPLICIT%>
<!--#include file="../include/db/connect_sqlserver.asp"-->
<%

session("isLog")=true
if session("isLog")=true then%>


......

<%
dim uSQL,rsServe,userName,departmentName,userPhone
searchDate=request("searchDate")
set rsServe=server.createobject("adodb.recordset")

uSQL="select userName,departmentName,userPhone from tbl_serve_user a,tbl_serve_department b where a.ID='"&session("ID")&"' and b.departmentID=a.departmentID "

rsServe.open uSQL,conn,3,2
if rsServe.eof then
response.write "系统出现故障,请和管理员联系!"
response.end
end if
userName=rsServe("userName")
departmentName=rsServe("departmentName")
userPhone=rsServe("userPhone")
rsServe.close

%>
大体意思是我要通过session获取登陆用户的用户名还有部门和电话
上面的连接应该是没有问题的,因为这个网站还能登陆
但是为什么一加上这些代码就不能打开那张网页了呢?
请高手指点

搜索更多相关主题的帖子: 数据库 语句 session userName 
2006-04-06 17:37
盖茨他爹
Rank: 6Rank: 6
等 级:贵宾
威 望:28
帖 子:5255
专家分:0
注 册:2005-5-3
收藏
得分:0 

提示什么错误?第几行?
加上哪段代码不能登陆?是不是这行?
[QUOTE]<%
session("isLog")=true
if session("isLog")=true then%>


......

<%
dim uSQL,rsServe,userName,departmentName,userPhone
searchDate=request("searchDate")
set rsServe=server.createobject("adodb.recordset")
uSQL="select userName,departmentName,userPhone from tbl_serve_user a,tbl_serve_department b where a.ID='"&session("ID")&"' and b.departmentID=a.departmentID "
rsServe.open uSQL,conn,3,2
if rsServe.eof then
response.write "系统出现故障,请和管理员联系!"
response.end
end if
userName=rsServe("userName")
departmentName=rsServe("departmentName")
userPhone=rsServe("userPhone")
rsServe.close
%>[/QUOTE]

我只看出来这里不对
[QUOTE]if rsServe.eof then
response.write "系统出现故障,请和管理员联系!"
response.end
end if
userName=rsServe("userName")
departmentName=rsServe("departmentName")
userPhone=rsServe("userPhone")[/QUOTE]
应该改成
[QUOTE]if rsServe.eof then
response.write "系统出现故障,请和管理员联系!"
response.end
else
userName=rsServe("userName")
departmentName=rsServe("departmentName")
userPhone=rsServe("userPhone")
end if[/QUOTE]

2006-04-06 18:24
青岛啤酒
Rank: 1
等 级:禁止访问
帖 子:186
专家分:0
注 册:2006-3-10
收藏
得分:0 
直接提示http500错误,
下面就是一个表格然后需要上面说得这几个字段

激情成就梦想!
2006-04-06 18:45
盖茨他爹
Rank: 6Rank: 6
等 级:贵宾
威 望:28
帖 子:5255
专家分:0
注 册:2005-5-3
收藏
得分:0 
贴上来偶看看

终于知道你是马甲了
2006-04-06 18:51
盖茨他爹
Rank: 6Rank: 6
等 级:贵宾
威 望:28
帖 子:5255
专家分:0
注 册:2005-5-3
收藏
得分:0 
设置一下浏览器,才能显示具体是那行出了错误,出了什么错误。这么设置:

工具——〉internet选项——〉高级——〉把“显示友好的错误信息”前面的对号给勾掉——〉按确定

然后再运行这个页面就显示具体什么错误了,然后把错误贴上来我看看
2006-04-06 18:54
卜酷塔
Rank: 7Rank: 7Rank: 7
来 自:魅力青岛
等 级:禁止访问
威 望:39
帖 子:2569
专家分:0
注 册:2004-6-12
收藏
得分:0 

<%OPTION EXPLICIT%>

<!--#include file="../include/db/connect_sqlserver.asp"-->
<!--#include file="../include/util.asp"-->
<%if session("isLog")=true then%>


<html>
<head>
<title>外包服务平台</title>
<meta http-equiv="Content-Type" content="text/html; charsRequestet=gb2312">
<link rel="stylesheet" href="../css/css.CSS">

<style type="text/css">
<!--
.style1 {
font-size: 24pt;
color: #0000FF;
}
-->
</style>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="requform" method="post" onsubmit="return submitit();" action="requeditsave.asp?requestID=<%=requestID%>">
<%
dim uSQL,rsUser,userClass
userClass=session("userClass")
set rsUser=server.createobject("adodb.recordset")
dim bm1,bm2,bm3,rsDepartment,parentID
if userClass=5 then

uSQL="select userName,userAccount,departmentID,DepartmentPlace,userPhone,userMail from tbl_request_user where ID='"&session("ID")&"'"
set rsUser=server.createobject("adodb.recordset")
rsUser.open uSQL,conn,3,1

set rsDepartment=server.createobject("adodb.recordset")

uSQL="select departmentName,parentID from tbl_request_department where departmentID='"&session("departmentID")&"'"
rsDepartment.open uSQL,conn,3,1
bm3=rsDepartment("departmentName")
parentID=rsDepartment("parentID")
rsDepartment.close
uSQL="select departmentName,parentID from tbl_request_department where departmentID='"&parentID&"'"
rsDepartment.open uSQL,conn,3,1
bm2=rsDepartment("departmentName")
parentID=rsDepartment("parentID")
rsDepartment.close
uSQL="select departmentName from tbl_request_department where departmentID='"&parentID&"'"
rsDepartment.open uSQL,conn,3,1
bm1=rsDepartment("departmentName")
rsDepartment.close

%>

<table class="listDataTable" id="DataTable" cellSpacing="2" cellPadding="1" width="695" border="1" style="border-collapse: collapse" bordercolor="#000000" height="322" align="center">

<caption class="style1">
<b>补添服务请求单</b> </caption>
<font color="#000000">
<tr id="ignore">
<td align="right" colSpan="6" height="2"></td>
</tr>
<tr>
<td width="84" height="22"><font color="#000000"><font color="#000000">提报人</font></font></td>
<td width="111"><FONT color=#000000>
<input name="userName" type="text" class="inputnormal" onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'" size="15">
</FONT></td>
<td width="82">联系电话</td>
<td width="123"><FONT color=#000000>
<input name="userPhone" type="text" class="inputnormal" onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'" size="15">
</FONT></td>
<td width="90">部门</td>
<td width="165"><FONT color=#000000>
<input name="departmentPlace" type="text" class="inputnormal" " onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'" size="15">
</FONT></td>
</tr>
<tr>
<td height="22" width="84"><font color="#000000"><font color="#000000">服务人员</font></font></td>
<td width="111">&nbsp;<%=userName%></td>
<td width="82"><font color="#000000">责任部门</font></td>
<td width="123">&nbsp;<%=departmentName%></td>
<td width="90"><font color="#000000">联系电话</font></td>
<td width="165">&nbsp;<%=rsUser("userPhone")%></td>
</tr>
<tr>
<td width="84" height="22">问题类型</td>
<td width="111" height="22"><font color="#000000"><FONT color=#000000>
<input name="errorType" type="text" class="inputnormal" onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'" size="15">
</FONT></font> </td>
<td width="82" height="22">紧急程度</td>
<td height="22" width="123"><FONT color=#000000>
<select name="requestUrge" id="select">
<option selected>-紧急程度-</option>
<option value="一般" >一般</option>
<option value="紧急">紧急</option>
</select>
</FONT> </td>
<td style="font-size: 9pt; color: #000000" id="tishi" width="90"><font color="#000000">请求时间</font></td>
<td id="tishi" style="font-size: 9pt; color: #000000" width="165"><FONT color=#000000><FONT
color=#000000>
<input name="sendTime" type="text" class="inputnormal" " onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'" size="15">
</FONT></FONT></td>
</tr>
<tr>
<td height="22">反馈时间</td>
<td height="22"><font color="#000000"> <FONT color=#000000><FONT color=#000000>
<input name="returnTime" type="text" class="inputnormal" " onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'" size="15">
</FONT></FONT></font></td>
<td id="tishi" style="font-size: 9pt; color: #000000">承诺时间</td>
<td id="tishi" style="font-size: 9pt; color: #000000"><FONT color=#000000><FONT color=#000000>
<input name="promissTime" type="text" class="inputnormal" " onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'" size="15">
</FONT></FONT></td>
<td height="22"><font color="#000000">服务完成时间</font></td>
<td height="22"><FONT color=#000000><FONT color=#000000>
<input name="serviceFinish" type="text" class="inputnormal" onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'" size="15">
</FONT></FONT></td>
</tr>
<tr>
<td colspan="6" height="2">报修描述</td>
</tr>
<tr>
<td colspan="6" height="41">
<div align="center"><font color="#000000">
<font color="#000000">
<textarea name="requestDescription" cols="95" rows="6" class="inputnormal" onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'"></textarea>
</font> </font> </div>
</td>
</tr>
<tr>
<td colspan="6" height="2">工程师反馈</td>
</tr>
<tr>
<td colspan="6" height="12">
<div align="center">
<FONT color=#000000><FONT color=#000000>
<textarea name="confirmContent" cols="95" rows="6" class="inputnormal" onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'"></textarea>
</FONT></FONT> </div>
</td>
</tr>
<tr>
<td colspan="6" height="2">故障描述</td>
</tr>
<tr>
<td colspan="6" height="58">
<div align="center">
<FONT color=#000000><FONT color=#000000>
<textarea name="wrongDescription" cols="95" rows="6" class="inputnormal" onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'"></textarea>
</FONT></FONT> </div>
</td>
</tr>
<tr>
<td colspan="6" height="2">故障原因</td>
</tr>
<tr>
<td colspan="6" height="63">
<div align="center">
<FONT color=#000000><FONT color=#000000>
<textarea name="wrongReasion" cols="95" rows="6" class="inputnormal" onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'"></textarea>
</FONT></FONT> </div>
</td>
</tr>
<tr>
<td colspan="6" height="2">解决方案</td>
</tr>
<tr>
<td colspan="6" height="2">
<div align="center"><font color="#000000">
<FONT color=#000000>
<textarea name="wrongSolution" cols="95" rows="6" class="inputnormal" onFocus="this.className='inputedit';this.select()" onBlur="this.className='inputnormal'"></textarea>
</FONT> </font> </div>
</td>
</tr>
<tr>
<td colspan="6" height="2">用户意见</td>
</tr>
<tr>
<td colspan="6" height="2">
<div align="center">
<textarea name="requ_desp" cols="95" class="areanormal" rows="6" readonly><%=evaluateFeedback%></textarea>
</div>
</td>
</tr>
<tr id="ignore">
<td height="2" colSpan="6" align="right"></td>
</tr>
</font>
</table>
<div align="right"><br>
<br>
<input name="Submit" type="submit" class="s02" value="提交">
<input type="button" name="Submit2" value="关闭" onclick="javascript:<% if session("userClass")="4" and requestState="0" then %>window.opener.document.location.reload(); <%end if%> self.close();" class="s02">
</div>
</form>
</body>
</html>


<%'else
'response.redirect "../default.asp"
'end if
%>


觉得为时已晚的时候,恰恰是最早的时候。

2006-04-10 10:08
卜酷塔
Rank: 7Rank: 7Rank: 7
来 自:魅力青岛
等 级:禁止访问
威 望:39
帖 子:2569
专家分:0
注 册:2004-6-12
收藏
得分:0 
报错提示如下:

Microsoft VBScript compilation error '800a03f6'

Expected 'End'

/daysummary/addorder.asp, line 210


觉得为时已晚的时候,恰恰是最早的时候。

2006-04-10 10:09
google
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:22
帖 子:3419
专家分:23
注 册:2005-11-1
收藏
得分:0 
丫代码还真长
头痛

祝天下所有母亲幸福安康!~
2006-04-10 10:27
快速回复:为什么这个语句不能连接到数据库?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029000 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved