木子屋 Dnawo's BLOG

一次有趣的ASP程序调试过程

👤 dnawo 📅 2007-07-27 👁 5605 👍 0 💬 0 🔄 来源:本站原创
Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

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

Microsoft VBScript 运行时错误 错误 '800a000d'

类型不匹配

/sfbbs/inc/Dv_ClsMain.asp,行710

碰到这样的错误提示我们应该高兴,因为它明确的指出了错误的地方,一般情况下只要检查下所在行的代码即可,但这次错误比较特别,710行处在一个函数体中,函数肯定是没有问题的,那么问题应该出在调用函数的地方,可是页面中有好几处调用了这个函数(难点一:确定出错位置);还有,这个函数主要的是一个循环体,我们还得判断出是在哪次循环时出的错(难点二)。OK,我们先来看下这个函数:

Public Function RecordsetToxml(Recordset,row,xmlroot)
	Dim i,node,rs,j,DataArray
	If xmlroot="" Then xmlroot="xml"
	If row="" Then row="row"
	Set RecordsetToxml=Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
	RecordsetToxml.appendChild(RecordsetToxml.createElement(xmlroot))
	If Not Recordset.EOF Then
		DataArray=Recordset.GetRows(-1)
		For i=0 To UBound(DataArray,2)
			Set Node=RecordsetToxml.createNode(1,row,"")
			j=0
			For Each rs in Recordset.Fields
					 node.attributes.setNamedItem(RecordsetToxml.createNode(2,LCase(rs.name),"")).text= DataArray(j,i)& "" [color=Red]'710行[/color]
					 j=j+1
			Next
			RecordsetToxml.documentElement.appendChild(Node)
		Next
	End If
	DataArray=Null
End Function

这个函数的功能还是比较简单的,主要就是建立一个FreeThreadedDOMDocument对象,其根节点是xmlroot,下边只有一个子节点row,然后将Recordset对象中的各字段及其值以属性的方式保存在row节点中。

好了,现在我们先来解决第一个难点:找出错误位置!修改RecordsetToxml函数如下:

Public Function RecordsetToxml(Recordset,row,xmlroot)
	Dim i,node,rs,j,DataArray
	If xmlroot="" Then xmlroot="xml"
	If row="" Then row="row"
	Set RecordsetToxml=Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
	RecordsetToxml.appendChild(RecordsetToxml.createElement(xmlroot))
	If Not Recordset.EOF Then
		DataArray=Recordset.GetRows(-1)
		For i=0 To UBound(DataArray,2)
			Set Node=RecordsetToxml.createNode(1,row,"")
			j=0
			For Each rs in Recordset.Fields
					 [color=Red]Response.Write(row & "  " & xmlroot & " " & rs.name & "<br/>")[/color]
					 node.attributes.setNamedItem(RecordsetToxml.createNode(2,LCase(rs.name),"")).text= DataArray(j,i)& "" '710
					 j=j+1
			Next
			RecordsetToxml.documentElement.appendChild(Node)
		Next
	End If
	DataArray=Null
End Function

注意Response.write语句放置的位置也很重要!浏览,返回结果为:

style xml ID
style xml StyleName
style xml Main_Style
style xml Style_Pic
style xml page_index
style xml page_dispbbs
style xml page_showerr
style xml page_login
style xml page_online
style xml page_usermanager
style xml page_fmanage
style xml page_boardstat
style xml page_paper_even_toplist
style xml page_query
style xml page_show
style xml page_dispuser
style xml page_help_permission
style xml page_postjob
style xml page_post
style xml page_boardhelp
style xml upsize_ts

Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

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

Microsoft VBScript 运行时错误 错误 '800a000d'

类型不匹配

/sfbbs/inc/Dv_ClsMain.asp,行711

可以初步判断是类似RecordsetToxml(Recordset,"style","xml")的位置出错,OK,我们搜索"style","xml",没有结果:(,再搜索"style",搜索结果中只有一处参数中有带"style"的,就是它了,发现也是位于一个函数中:

Public Sub Loadstyle()
	Dim Rs
	Set Rs=Dvbbs.Execute("Select *  From Dv_style")
	Set Application(CacheName &"_style")=RecordsetToxml(rs,"style","")[color=Red] '就是这句了[/color]
	Set Rs=Nothing
	LoadStyleMenu()
End Sub

这个函数的作用也挺简单的,就是从Dv_style表中将论坛样式读取出来以XML格式保存到Application对象中,OK,结合上边错误信息,我们可以猜到是在读取upsize_ts字段时出错了!才想起来这个字段动网本身是没有的,是在Access2000转Access2003时新增的,将其删除,问题解决!

评论(0)

暂无评论。

验证码
评论需审核通过后显示
← 上一篇 Dvbbs7.1Access转MsSQL错误汇总 下一篇 → [译]对程序员新手的善意忠告