主题:  程序调试出错专答区

AdderKing

职务:普通成员
等级:1
金币:0.0
发贴:12
#312005/2/28 11:29:00
好了 原来我的机器出错误了
重新启动了一下就好了
可这是什么原因呢
在asp中如何避免服务器的错误

刚刚我只是在一个页面上做了一个联接
<a href ='sur_del.asp?id='<%=id%>>删除</a>
点了一下就。。。
sur_del.asp这文件还没有做

编辑历史:[此帖最近一次被 Adder 编辑过(编辑时间:2005-02-28 11:57:20)]


缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
#322005/2/28 12:45:46
<a href ='sur_del.asp?id=<%=id%>'>删除</a>



csdjyzd

职务:普通成员
等级:1
金币:0.0
发贴:35
#332005/3/29 8:12:58
<%@ Language=Jscript %>

<%

var conn=Server.CreateObject("ADODB.Connection");
conn.ConnectionString= "Provider=SQLOLEDB;server=127.0.0.1;Uid=sa;pwd=;database=student";    
conn.Open();
var str2=String(Request.Form("x2"));
var str1=String(Request.Form("x1"));
    var rs = Server.CreateObject("ADODB.Recordset");

    var sql = "Select * from student_class where user_name="+str1;
    rs.Open(sql,conn,3);
if (!rs.eof)
{ var str3=String(rs("password"));

if (str2==str3)
{Response.Redirect("post_question.asp?Uname="+str1)}
else
{Response.Redirect("index.asp")};
}
else
{Response.Redirect("index.asp")};

%>

这是我做的登陆的代码。。可是输入数据库中正确的登陆名和密码却不能登陆。。
我试着把str2和str3两个变量都返回。。值是一样的。。都是我输入的5818
但是,为什么IF比较的时候会不一样??两个变量的类型我都已经统一为String了
会不会是数据库的数据包含空格??
我用Trim(rs("password"))想去空格,可调试的时候说缺少对象
原来写VS的脚本用trim都可以的啊。。怎么换了JS就不好用了???
是不是JS不是用trim去空格??

编辑历史:[此帖最近一次被 csdjyzd 编辑过(编辑时间:2005-03-29 09:15:46)]


缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
#342005/3/29 9:16:21
js没有trim函数.这中语言的语法函数都是有区别的,不要想当然.

你分别输出str2和str3以及各自的length来对比人工对比一下,看看问题在哪儿



csdjyzd

职务:普通成员
等级:1
金币:0.0
发贴:35
#352005/3/29 12:06:35
我发现是数据库取出的str3有问题
它的长度是10
肯定是后面有空格。。
请问用JS怎么去掉空格??

编辑历史:[此帖最近一次被 csdjyzd 编辑过(编辑时间:2005-03-29 12:39:09)]


缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
#362005/3/29 12:32:54
str2.length

建议学习一下js的相关语法.如果用VBS的语法来写js,那么为什么还要分JS和VBS呢?



csdjyzd

职务:普通成员
等级:1
金币:0.0
发贴:35
#372005/3/29 12:42:28
谢谢。。。我刚试了半天才知道是用str3.length
但是它的长度多出了6位,我想应该是空格的原因。。。
请问怎么去掉呢 ??~~



csdjyzd

职务:普通成员
等级:1
金币:0.0
发贴:35
#382005/3/29 13:41:35
我用substring取str3和str2等长的前一截倒是可以实现功能~~
不过,JS里面就没有一个可以去前后空格的函数吗??



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
#392005/3/29 14:23:53
str2.replace(/ /,"")



进军.net

职务:普通成员
等级:1
金币:0.0
发贴:105
#402005/3/30 13:57:39
用on error resume next或忽略错误,on error resume 0重新恢复出错机制


--------------------------------------------------------------------------------

我看的asp书中对这个介绍很少,不太明白这个东西!那有这样的学习资料请指点一二。
谢谢!



zm8111

职务:普通成员
等级:1
金币:0.0
发贴:3
#412005/4/3 14:14:51
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace="System.Data.OleDb"%>
<%@ Page Language="C#" Debug="true" %>
<html>

<script language = "C#" runat = "server">

void Page_Load()
{

string strConnection="Provider=Microsoft.Jet.OleDb.4.0;Data Source=";
strConnection+=@"Data Source=D:\website\test.mdb";
//strConnection+=Server.MapPath("test.mdb");


OleDbConnection objConnection = new OleDbConnection(strConnection);
OleDbDataAdapter objDataAdapter = new OleDbDataAdapter("select * from test.mdb",objConnection);

DataSet objDataSet = new DataSet();
objDataAdapter.Fill(objDataSet);

MyGrid.DataSource = objDataSet;
MyGrid.DataBind();

}

void MyGrid_PageIndexChanged(Object sender, DataGridPageChangedEventArgs e)
{
MyGrid.CurrentPageIndex = e.NewPageIndex;
DataBind();



}

</script>


<body>

<asp:DataGrid id = "MyGrid"
cellpadding = "1"
                 showheader = "true"
                 boderwidth = "0"
                 allowpaging = "true"
                 pagesize = "3"
                 onpageindexchanged = "MyGrid_PageIndexChanged"
                 runat = "server"/>


</body>

</html>

*********************

“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------

文件名无效。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Data.OleDb.OleDbException: 文件名无效。

源错误:


行 18:
行 19: DataSet objDataSet = new DataSet();
行 20: objDataAdapter.Fill(objDataSet);行 21:
行 22: MyGrid.DataSource = objDataSet;


源文件: D:\website\test\dbtest_fengye.aspx 行: 20

堆栈跟踪:


[OleDbException (0x80004005): 文件名无效。]
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) +20
System.Data.OleDb.OleDbConnection.InitializeProvider() +57
System.Data.OleDb.OleDbConnection.Open() +203
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
ASP.dbtest_fengye_aspx.Page_Load() in D:\website\test\dbtest_fengye.aspx:20
System.Web.Util.ArglessEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +10
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731



啥问题啊?搞不懂了
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573



蓝鲸

职务:版主
等级:5
金币:42.1
发贴:2614
#422005/4/3 19:17:13
select * from test.mdb???


非常大鱼

hongyishizhe

职务:普通成员
等级:1
金币:0.0
发贴:21
#432005/5/22 14:19:57
这个统计访问人数的程序不完善,点刷新,人数会增加,帮忙指正一下,错在哪?
<%@ import namespace="system" %>
<%@ import namespace="system.io" %>
<script language="vb" runat="server">
sub page_load(sender as object, e as eventargs)

dim objreader as new streamreader(server.MapPath("counter3.txt"))
dim counter as long = objreader.readline()
objreader.close()
if session.IsNewSession = true then
counter += 1
dim objwrite as new streamwriter(server.MapPath("counter3.txt"), false)
objwrite.writeline(counter)
    objwrite.close()
    

label1.text=counter

end if

end sub

</script>




<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form runat="server">
<asp:Label runat="server" ID="label1"/>

</form>
</body>
</html>



camalj

职务:普通成员
等级:1
金币:0.0
发贴:7
#442005/9/7 10:38:42
Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

/iisHelp/common/500-100.asp,行242

Microsoft OLE DB Provider for ODBC Drivers 错误 '80004005'

[Microsoft][ODBC 驱动程序 管理器] 驱动程序的 SQLSetConnectAttr 失败

/index.asp,行8
菜鸟问题:请教如何解决,源代码如下,xp运行正常,但2000运行出现上述错误

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/conn.asp" -->
<%
Dim rs
Dim rs_numRows

Set rs=Server.CreateObject("ADODB.Recordset"
rs.ActiveConnection=MM_conn_STRING
rs.Source="SELECT * FROM userbook ORDER BY id DESC"
rs.CursorType= 0
rs.CursorLocation=2
rs.LockType=1
rs.Open()

rs_numRows=0
%>
<%
' *** Validate request to log in to this site.
MM_LoginAction=Request.ServerVariables("URL"
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername=CStr(Request.Form("name")
If MM_valUsername <> "" Then
MM_fldUserAuthorization=""
MM_redirectLoginSuccess="index1.asp"
MM_redirectLoginFailed="index.asp"
MM_flag="ADODB.Recordset"
set MM_rsUser=Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_conn_STRING
MM_rsUser.Source="SELECT username, password"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source=MM_rsUser.Source & "," & MM_fldUserAuthorization
MM_rsUser.Source=MM_rsUser.Source & " FROM userbook WHERE username='" & Replace(MM_valUsername,"'","''" &"' AND password='" & Replace(Request.Form("password","'","''" & "'"
MM_rsUser.CursorType=0
MM_rsUser.CursorLocation=2
MM_rsUser.LockType=3
MM_rsUser.Open
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username"=MM_valUsername
If (MM_fldUserAuthorization <> "" Then
Session("MM_UserAuthorization"=CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).value)
Else
Session("MM_UserAuthorization"=""
End If
if CStr(Request.QueryString("accessdenied") <> "" And true Then
MM_redirectLoginSuccess=Request.QueryString("accessdenied"
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%>
<!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">
<!--
a:link {
    text-decoration: none;
    color: #FFFFFF;
}
a:visited {
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
    color: #00CCFF;
}
a:active {
    text-decoration: none;
}
h1,h2,h3,h4,h5,h6 {
    font-family: Arial, Helvetica, sans-serif;
}
body {
    background-image: url(image/ad_bg.gif);
}
.style3 {font-size: 9pt}
.style4 {font-size: 9pt; color: #686557; }
.style9 {color: #1F69C0}
.style10 {font-size: 10pt}
.style11 {color: #FFFFFF}
.style13 {color: #FFFFFF; font-size: 9pt; }
a {
    font-weight: bold;
}
.style14 {color: #00CCFF}
-->
</style></head>

<body>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="856" height="60"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" height="65"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="25%" height="91">&nbsp;</td>
<td background="image/bg1.jpg">&nbsp;</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="13" background="&#25391;&#20013;&#25945;&#32946;/image/ad_bg1.jpg"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="image/ad_bg1.jpg">
<tr>
<td width="25%" height="29">&nbsp;</td>
<td width="75%"><table width="82%" height="16" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="center" valign="middle" class="style4">
<td width="60" class="style11"><a href="index.asp" class="style11">首 页</a></td>
<td><img src="image/daohang_bj_1.gif" width="1" height="15"></td>
<td width="60"><span class="style11">中 考</span></td>
<td><img src="image/daohang_bj_1.gif" width="1" height="15"></td>
<td width="60"><span class="style11">高 考</span></td>
<td><img src="image/daohang_bj_1.gif" width="1" height="15"></td>
<td width="60"><span class="style11">网上书店</span></td>
<td><img src="image/daohang_bj_1.gif" width="1" height="15"></td>
<td width="60"><span class="style11">资源下载</span></td>
<td><img src="image/daohang_bj_1.gif" width="1" height="15"></td>
<td width="60"><span class="style11">联系我们</span></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="542"><table width="100%" height="409" border="0" cellpadding="0" cellspacing="0">
<tr align="center" valign="top">
<td width="23%" height="409" bgcolor="#E4EEF8"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="75"><table width="100%" height="172" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="image/index_11.jpg" width="175" height="41"></td>
</tr>
<tr>
<td align="center" valign="middle"><form ACTION="<%=MM_LoginAction%>" name="form1" method="POST">
<p><span class="style4">用户名</span><span class="style3">:</span>
<input name="name" type="text" id="name" size="12">
</p>
<p><span class="style4">密 码</span><span class="style3">:</span>
<input name="password" type="password" id="password" size="12">
</p>
<p><img src="image/index_21.jpg" width="27" height="16">
<input type="submit" name="Submit" value="登录">
<img src="image/index_23.jpg" width="64" height="18"> </p>
</form></td>
</tr>
<tr>
<td height="20" align="center" valign="middle"><p>&nbsp; </p>
</td>
</tr>
</table></td>
</tr>
<tr>
<td height="100"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25" colspan="2">&nbsp;</td>
</tr>
<tr align="center" valign="middle">
<td colspan="2"><p><img src="image/index_16.jpg" width="175" height="24"></p>
</td>
</tr>
<tr>
<td width="27%" align="right" valign="middle"><img src="image/i4.gif" width="10" height="12"></td>
<td width="73%" align="center" valign="middle" class="style4">点卡充值</td>
</tr>
<tr>
<td align="right" valign="middle"><img src="image/i4.gif" width="10" height="12"></td>
<td align="center" valign="middle" class="style4">点卡使用流程</td>
</tr>
<tr>
<td align="right" valign="middle"><img src="image/i4.gif" width="10" height="12"></td>
<td align="center" valign="middle" class="style4">账户信息</td>
</tr>
<tr>
<td align="right" valign="middle"><img src="image/i4.gif" width="10" height="12"></td>
<td align="center" valign="middle" class="style4">会员制度</td>
</tr>
<tr>
<td align="right" valign="middle"><img src="image/i4.gif" width="10" height="12"></td>
<td align="center" valign="middle" class="style4">常见问题</td>
</tr>
<tr>
<td align="right" valign="middle"><img src="image/i4.gif" width="10" height="12"></td>
<td align="center" valign="middle" class="style4">意见建议</td>
</tr>
<tr>
<td align="right" valign="middle"><img src="image/i4.gif" width="10" height="12"></td>
<td align="center" valign="middle" class="style4">联系方式</td>
</tr>
</table></td>
</tr>
<tr>
<td height="175"><table width="100%" height="160" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="30"><img src="image/index_43.gif" width="171" height="25"></td>
</tr>
<tr>
<td><FONT
color=#003399 class="style4">您具备教案编写的能力吗?<BR>
来吧,您将有机会加盟无忧网校,凭您的实力将成为无忧网校的明星教师。<BR>
欢迎兼职教师加盟 <BR>
我要申请 </FONT></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="77%"><table width="100%" height="480" border="0" cellpadding="0" cellspacing="0" bgcolor="#EFF5FC">
<tr>
<td height="142"><table width="85%" height="140" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="61%" height="41"><img src="image/index_3.jpg" width="417" height="41"></td>
<td width="39%"><img src="image/index_2.jpg" width="163" height="41"></td>
</tr>
<tr>
<td height="99"><table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="32%"><img src="image/pic_01.jpg" width="122" height="154"></td>
<td width="68%"> <span class="style9">&nbsp;&nbsp;<span class="style10">教育部学位与研究生教育发展中心(简称教育部学位中心)是教育部直属事业单位,在教育部和国务院学位委员会的领导下开展工作。教育部学位中心具有独立法人资格,是具有社会中介机构性质的、非营利性的社会组织。教育部学位中心成立于2003年7月2日,其前身是挂靠在清华大学的全国学位与研究生教育发展中心。 <br>
   学位中心工作职能: <br>
   开展学位与研究生教... [详细内容</span>] </span></td>
</tr>
</table></td>
<td background="image/index_4.jpg">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td height="54" align="center" valign="top"><table width="100%" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><img src="image/index_5.jpg" width="289" height="26"></td>
<td><div align="left"><img src="image/index_6.jpg" width="289" height="26"></div></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><div align="right"><img src="image/c2.gif" width="44" height="15"></div></td>
<td><div align="right"><img src="image/c2.gif" width="44" height="15"></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="231" valign="top"><table width="100%" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><img src="image/index_7.jpg" width="289" height="26"></td>
<td><div align="left"><img src="image/index_8.jpg" width="289" height="26"></div></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><div align="right"><img src="image/c2.gif" width="44" height="15"></div></td>
<td><div align="right"><img src="image/c2.gif" width="44" height="15"></div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="44" align="center" bgcolor="#468CC7"><table width="82%" height="16" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="center" valign="middle" class="style4">
<td><span class="style11">关于本站</span></td>
<td><img src="image/daohang_bj_1.gif" width="1" height="15"></td>
<td><span class="style11">网站地图</span></td>
<td><img src="image/daohang_bj_1.gif" width="1" height="15"></td>
<td><span class="style11">网站招聘</span></td>
<td><img src="image/daohang_bj_1.gif" width="1" height="15"></td>
<td><span class="style11">广告服务</span></td>
<td><img src="image/daohang_bj_1.gif" width="1" height="15"></td>
<td><span class="style11">版权声明</span></td>
<td><img src="image/daohang_bj_1.gif" width="1" height="15"></td>
<td><span class="style11">练习我们</span></td>
</tr>
</table> </td>
</tr>
<tr>
<td height="59" align="center" bgcolor="#468CC7"><p class="style11 style3">版权所有:振中教育中心 网站设计:蒋汉成</p>
<p class="style13"> Copyright?2005 All Rights Reserved</p> <p class="style13">地址:河南省洛阳市</p> </td>
</tr>
</table> </td>
</tr>
</table>
<div align="center"></div>
</body>
</html>
<%
rs.Close()
Set rs=Nothing
%>



gu025

职务:普通成员
等级:1
金币:0.0
发贴:6
#452005/12/22 20:00:16
我用一个用户名登录到论坛,发了新贴后,发贴人这栏没有用户名,显示空白的,
相关语句:StrSql = "insert into msginfo(usercode,title,content,dtime) values('" + user + "','" & SendTitle & "','" + SendContent + "','" + Now + "')"
我在SQL中插入贴子后,发贴人这栏都有显示的,为什么运行的时候发新贴显示不出用户呢?