asp 模板自定义标签问题

当“DB1”这个字段是汉字时怎么取不出?'【功能】处理自定义模板标签FunctionProcessCustomTags(ByValsContent)DimobjRegEx... 当“DB1”这个字段是汉字时怎么取不出?

'【功能】处理自定义模板标签
Function ProcessCustomTags(ByVal sContent)
Dim objRegEx, Match, Matches
'建立正则表达式
Set objRegEx = New RegExp
'查找内容
objRegEx.Pattern = "<tag:[^<>]+?\/>"
'忽略大小写
objRegEx.IgnoreCase = True
'全局查找
objRegEx.Global = True
'Run the search against the content string we've been passed
Set Matches = objRegEx.Execute(sContent)
'循环已发现的匹配
For Each Match in Matches
'Replace each match with the appropriate HTML from our ParseTag function
sContent = Replace(sContent, Match.Value, ParseTag(Match.Value))
Next
'消毁对象
set Matches = nothing
set objRegEx = nothing
'返回值
ProcessCustomTags = sContent
End Function

'【功能】取得模板标签的参数名
'如:<tag:loop channelid="1" pagesize="10" title="20" type="NEW" column="1">
function GetAttribute(ByVal strAttribute, ByVal strTag)
Dim objRegEx, Matches
'建立正则表达式
Set objRegEx = New RegExp
'查找内容 (the attribute name followed by double quotes etc)
objRegEx.Pattern = lCase(strAttribute) & "=""[0-9a-zA-Z]*"""
'忽略大小写
objRegEx.IgnoreCase = True
'全局查找
objRegEx.Global = True
'执行搜索
Set Matches = objRegEx.Execute(strTag)
'如有匹配的则返回值, 不然返回空值
if Matches.Count > 0 then
GetAttribute = Split(Matches(0).Value,"""")(1)
else
GetAttribute = ""
end if
'消毁对象
set Matches = nothing
set objRegEx = nothing
end function

'【功能】解析并替换相应的模板标签内容
function ParseTag(ByVal strTag)
dim arrResult, ClassName, arrAttributes, sTemp, i, objClass
'如果标签是空的则退出函数
if len(strTag) = 0 then exit function
'Split the match on the colon character (:)
arrResult = Split(strTag, ":")
'Split the second item of the resulting array on the space character, to
'retrieve the name of the class
ClassName = Split(arrResult(1), " ")(0)
'Use a select case statement to work out which class we're dealing with
'and therefore which properties to populate etc
select case uCase(ClassName)
'It's a loop class, so instantiate one and get it's properties
case "LOOP"
set objClass = new WawaLoop
objClass.Channelid= GetAttribute("channelid", strTag)
objClass.Pagesize= GetAttribute("pagesize", strTag)
objClass.title = GetAttribute("title", strTag)
'objClass.Elite = GetAttribute("elite", strTag)
ParseTag =objClass.column (GetAttribute("column", strTag))
set objClass = nothing
end select
end function
Class WawaLoop
public Channelid,Pagesize,title,conn
Private Sub Class_Initialize()
dim connstr
dim db
db="/Data/wrmps.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.Open connstr
End Sub
Public Function column(strColumn)
dim i,rs,sql,strtemp
i = 1
set rs=server.CreateObject("adodb.recordset")
sql = "select top "&Pagesize&" * from ClassAD where DB1='Channelid'"
rs.open sql,conn,1,1
do while not rs.eof
strtemp = strtemp& "<li><span class=""Class_box_time"">"
strtemp = strtemp& "8/31</span><font class=""F13"">"
strtemp = strtemp& "["&lefttrue(rs("DB1"),4)&"]</font> <a href=""/Class/Show.asp?ID=33"" target=""_blank"">"
strtemp = strtemp& ""&lefttrue(rs("Title"),28)&"</a></li>"
if (i mod strColumn) =0 then
end if
rs.movenext
i=i+1
loop
rs.close:set rs = nothing
column = strtemp
End Function
End Class
展开
 我来答
永焮荣05e
2010-08-15 · TA获得超过1151个赞
知道小有建树答主
回答量:1125
采纳率:0%
帮助的人:453万
展开全部
这个楼上说的是不对的吧,编码不会影响读不出来的
楼主说汉字的时候才读不出来,那就是普通情况下是能够读出来的?
建议检查lefttrue函数,我觉得应该是楼主不小心引起的,如果可以可以加我并且发相关代码过来帮你测试
百度网友a1124be47
2010-08-12 · TA获得超过1232个赞
知道小有建树答主
回答量:918
采纳率:0%
帮助的人:975万
展开全部
1.是不是语句错误?改成下面试下:
sql = "select top "&Pagesize&" * from ClassAD where DB1='"&Channelid&"'"
2.Channelid取到值没有?编码是否一致?
3.lefttrue是自定义函数吗?是不是这个函数的问题?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式