| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2610 人关注过本帖
标题:如何加强文章简介的截取功能 (附:解决问题之后的小结)
只看楼主 加入收藏
frankqnj
Rank: 4
等 级:贵宾
威 望:12
帖 子:320
专家分:278
注 册:2008-4-6
收藏
得分:0 
直接用 楼上几位给的 html 标签过滤 功能是可行的

你出错的原因 应该不是代码本身,而是直接 复制或粘贴 时产生的. 特殊字符信息 也进到代码里去了
2008-05-01 02:05
zslj
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2008-4-28
收藏
得分:0 

好的,打包邮件你啦!
2008-05-01 02:10
zslj
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2008-4-28
收藏
得分:0 
[bo]以下是引用 [un]google[/un] 在 2008-5-1 01:45 的发言:[/bo]

方便的话把数据库,CONN文件和INDEX文件给我我看看。只要这套相关的就可以了


哈哈,相关文件如下:
INDEX.ASP
-------------------------------------------------------------------------------------
<%@ Language=VBScript %>

<!--#include file="Script/adovbs.inc"-->
<%dim view
view=Request.QueryString("view")

'打开数据库
dim objConn, strCon, objRS, strSQL
Set objConn = Server.CreateObject("ADODB.Connection")
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("shujuku\shujuku.mdb")
objConn.connectionstring = strCon
objConn.Open
Set objRS = Server.CreateObject("ADODB.Recordset")
'出现错误重新开始
%>

<html>
<head>
    <title>冷锋博客</title>
    <link rel="stylesheet" type="text/css" href="Script/style.css">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<p>
<div align="center">
<table width="700" border="0" cellpadding="0" cellspacing="0">
    <tr><!--头部-->    
        <td colspan="2" width="700" height="58" align="right" valign="top" background="images/banner.gif">
        <a href="index.asp" title="返回博客首页">博客首页</a>&nbsp;|&nbsp;<a href="javascript:t2s()" style="text-decoration: none">简体</a>&nbsp;|&nbsp;<a href="javascript:s2t()" style="text-decoration: none">繁体</a>&nbsp;|&nbsp;<a href="gbook.asp">留言</a>&nbsp;|&nbsp;<a href="admin.asp">管理</a>&nbsp;</td>
    </tr>
<!--头部结束-->    
    <tr>
        <td width="500" height="100%">
<!--左侧博客文章栏开始-->
            <table width="500" height="100%" border="0" cellpadding="5" cellspacing="0">
                <tr>
                    <td valign="top" width="500" height="100%" class="blog">
<!--首页预览文章-->            <% IF view="" THEN
                            dim counter, blogEntry
                            counter=0
                            ' 设置 SQL 语句从数据库获得信息
                            strSQL="SELECT * FROM TBLBlog WHERE Status=1 ORDER BY id DESC"
                            ' 打开数据库
                            objRS.Open strSQL, objConn, adOpenKeyset, adLockPessimistic, adCmdText
                            %>
                            首页 (最新博客文章预览)
                            <hr size="1" noshade style="color:#000000" width="100%">
                            <%
                            counter=0
                            DO UNTIL counter=7 OR objRS.EOF        '首页显示新文章预览的数目
                            %>
                            <table width="100%" class="blogEntry">
                                <tr>
                                    <td><b><%=objRS("entryTitle")%></b></td>
                                    <td align="right">写于 <%=objRS("byear")%>年<%=objRS("bmonth")%>月<%=objRS("bday")%>日 <%=objRS("btime")%> </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="blog2">
                                    <%blogEntry = Replace(objRS("entry"), vbCrLf, "<br>")
                                    ' 检查输入长度,如果超出必然的字符数就截断
                                    IF Len(blogEntry) > 50 THEN
                                    blogEntry=left(blogEntry,50)
                                    blogEntry=blogEntry+" ......<a href=""index.asp?view=display&ID="&objRS("id")&"""><img src=""images/read.gif"" width=""25"" height=""22"" alt=""阅读全文"" border=""0"" align=""right"" valign=""bottom""></a>"
                                    END IF
                                    Response.Write(blogEntry)
                                    %>
                                    </td>
                                </tr>
                            </table>
                            <br>
                            <%counter=counter+1
                            objRS.MoveNext
                            Loop
                            objRS.Close
                            %>
                            <%END IF%>
<!---显示文章的全文---->
                            <%IF view="display" THEN
                            '显示选定的文章的全文
                            ' 设置 SQL 语句从数据库获得信息
                            strSQL="SELECT * FROM TBLBlog WHERE id="&Request.QueryString("ID")
                            ' 打开数据库
                            objRS.Open strSQL, objConn, adOpenKeyset, adLockPessimistic, adCmdText
                            objRS("bread") = objRS("bread") + 1
                            objRS.Update
                            %>
                        <a href="index.asp" title="博客首页">首页</a>&nbsp;>>&nbsp;阅读博客文章全文
                        <hr size="1" noshade style="color:#000000" width="100%">
                    <table width="100%" class="blogEntry" style="table-layout: fixed;word-wrap:break-word;">
                    <!---防止大图片撑大表格 style="table-layout: fixed;word-wrap:break-word; ---->
                        <tr>
                            <td><b><%=objRS("entryTitle")%></b></td>
                            <td align="right">写于 <%=objRS("byear")%>年<%=objRS("bmonth")%>月<%=objRS("bday")%>日 <%=objRS("btime")%></td>
                        </tr>
                        <tr>
                            <td width="100%" colspan="2" class="blog2" style="word-wrap:break-word;">
                                <P><br>
                                <%
                                blogEntry = Replace(objRS("entry"), vbCrLf, "")
                                Response.Write(blogEntry)
                                %>
                                </P>
                            </td>
                        </tr>
                    </table>
                    <br>
                    <DIV>
                      <div align="right">本文共浏览&nbsp;<%=objRS("bread")%>&nbsp;次&nbsp;</div>
                    </DIV>
                    <br>
                    <%END IF%>
<!---显示显示选定日期的文章---->                    
                    <%
                        IF view="archive" THEN
                        ' 设置 SQL 语句从数据库获得信息
                        strSQL="SELECT * FROM TBLBlog WHERE Status=1 AND bday="&Request.QueryString("day")&" AND bmonth="&Request.QueryString("month")&" AND byear="&Request.QueryString("year")
                        ' 打开数据库
                        objRS.Open strSQL, objConn
                    %>
                    <a href="index.asp" title="博客首页">首页</a>&nbsp;>>&nbsp;查看<%=Request.QueryString("year")%>年<%=Request.QueryString("month")%>月<%=Request.QueryString("day")%>日的博文
                        <hr size="1" noshade style="color:#000000" width="100%">
                    <%
                        IF NOT objRS.EOF THEN
                        DO WHILE NOT objRS.EOF
                     %>
<!--选定日的文章预览表格开始-->    
                            <table width="100%" class="blogEntry">
                                <tr>
                                    <td><b><%=objRS("entryTitle")%></b></td>
                                    <td align="right">写于 <%=objRS("byear")%>年<%=objRS("bmonth")%>月<%=objRS("bday")%>日 <%=objRS("btime")%> </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="blog2">
                                    <%blogEntry = Replace(objRS("entry"), vbCrLf, "<br>")%>
                                    <%' 检查输入长度,如果超出必然的字符数就截断
                                    IF Len(blogEntry) > 35 THEN
                                    blogEntry=left(blogEntry,35)
                                    blogEntry=blogEntry+" ......<a href=""index.asp?view=display&ID="&objRS("id")&"""><img src=""images/read.gif"" width=""25"" height=""22"" alt=""阅读全文"" border=""0"" align=""right"" valign=""bottom""></a>"
                                    END IF
                                    Response.Write(blogEntry)
                                    %>
                                    </td>
                                </tr>
                            </table>
                            <br>
                    <%
                        objRS.MoveNext
                        Loop
                        ELSE
                    %>
                    <br>
                    <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td valign="top">本日无博客文章 ...</td>
                      </tr>
                    </table>
                    <%END IF%>
                    <%END IF%>
<!---显示选定月份的文章---->
                    <% IF view="archiveMonth" THEN
                    '显示选定的日子进入
                    ' 设置 SQL 语句从数据库获得信息
                    strSQL="SELECT * FROM TBLBlog WHERE Status=1AND bmonth="&Request.QueryString("month")&" AND byear="&Request.QueryString("year")&" ORDER BY bday DESC"
                    ' 打开数据库
                    objRS.Open strSQL, objConn%>
                    <a href="index.asp" title="博客首页">首页</a>&nbsp;>>&nbsp;查看<%=Request.QueryString("year")%>年<%=Request.QueryString("month")%>月份的博文
                        <hr size="1" noshade style="color:#000000" width="100%">
                    <%
                    IF NOT objRS.EOF THEN
                    DO WHILE NOT objRS.EOF
                    %>
<!--选定月文章预览表格开始-->    
                            <table width="100%" class="blogEntry">
                                <tr>
                                    <td><b><%=objRS("entryTitle")%></b></td>
                                    <td align="right">写于 <%=objRS("byear")%>年<%=objRS("bmonth")%>月<%=objRS("bday")%>日 <%=objRS("btime")%> </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="blog2">
                                    <%blogEntry = Replace(objRS("entry"), vbCrLf, "<br>")%>
                                    <%' 检查输入长度,如果超出必然的字符数就截断
                                    IF Len(blogEntry) > 35 THEN
                                    blogEntry=left(blogEntry,35)
                                    blogEntry=blogEntry+" ......<a href=""index.asp?view=display&ID="&objRS("id")&"""><img src=""images/read.gif"" width=""25"" height=""22"" alt=""阅读全文"" border=""0"" align=""right"" valign=""bottom""></a>"
                                    END IF
                                    Response.Write(blogEntry)
                                    %>
                                    </td>
                                </tr>
                            </table>
                            <br>
                    <%
                    objRS.MoveNext
                    Loop
                    ELSE
                    %>
<!--没有文章的提示-->                    
                    <br>
                    <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td valign="top">本月无博客文章 ...</td>
                      </tr>
                    </table>
                    <%END IF%>
                    <%END IF%>
                    </td>
                </tr>
          </table>
</td>
<!--左侧栏结束-->    

<!--右侧栏开始-->            
<td width="200" align='center' class="blog3" valign="top"><br>
<!--博客日历开始-->
            <!--#include file="calendar.asp"--><BR>
<!--博客日历结束-->
            <hr size="1" noshade style="color:#915BA3" width="100%">
            <table border="0" width="180" class="blogEntry" cellspacing="0" cellpadding="2">
                <tr>
                    <td align="center" valign="bottom"><b>在线访问计数</b>
                        <hr size="1" noshade style="color:#000000" width="100%">
                            <table border="0" width="90%" cellspacing="0">
                                <tr>
                                    <td><!--#include file="count/count.asp"--></td>
                            </table>
                  </td>
              </tr>
  </table>
            <hr size="1" noshade style="color:##915BA3" width="100%">
            <table width="180" border="0" cellpadding="2" cellspacing="0" class="blogEntry">
                <tr>
                    <td valign="top"><center><b>友情链接</b></center>
                        <hr size="1" noshade style="color:#000000" width="100%">
                            <table width="90%" border="0" cellspacing="0">
                                <tr>
                                    <td width="50%" valign="top">
                                      <div align="center">
                                      &nbsp;●&nbsp; <a href="https://bbs.bccn.net/" target="_blank" class="tiny" title="中国最大的编程者社区">编程论坛</a><BR>
                                      &nbsp;●&nbsp; <a href="http://www. target="_blank" class="tiny" title="图片素材资源网">桌面城市</a><BR>
                                    </td><td width="50%" valign="top">
                                     &nbsp;●&nbsp; <a href="#" target="_blank" class="tiny" title="友情链接">友情链接</a><BR>
                                      &nbsp;●&nbsp; <a href="#" target="_blank" class="tiny" title="友情链接">友情链接</a><BR>
                                       &nbsp;●&nbsp; <a href="#" target="_blank" class="tiny" title="友情链接">友情链接</a><BR>
                                      </div></td>
                                </tr>
                            </table><BR>
                  </td>
              </tr>
  </table>
<BR>

<!--右侧栏结束-->
            </td>
        </tr>
</table>
<BR>
<table width="500" border="0" cellspacing="0" cellpadding="10">
  <tr>
    <td align="center" valign="middle">本站由<a href="http://www. target="_blank"><img src="http://www. border="0" align="absmiddle"></a>&nbsp;&nbsp;提供免费服务</td>
  </tr>
</table>
<BR>
</div>
<!--脚本容错代码-->
<SCRIPT LANGUAGE="JavaScript">
<!--
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>
<!--体部文字简繁转换-->
<script type="text/JavaScript">setFileFileds(document.forms[0].select.value);</script>
</body>
</html>
<!--加载简繁转换脚本-->
<script type="text/JavaScript" language="JavaScript" src="Script/transform.js"></script>
<script type="text/JavaScript" language="JavaScript">
function s2t(){
  document.body.innerHTML=document.body.innerHTML.s2t();
}
function t2s(){
  document.body.innerHTML=document.body.innerHTML.t2s();
}
</script>
-----------------------------------------------------------------------------------

adovbs.inc
-------------------------------------------------------------------------------------
<%

'---- CursorTypeEnum Values ----
'Const adOpenForwardOnly = 1
'Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3

'---- CursorOptionEnum Values ----
Const adHoldRecords = &H00000100
Const adMovePrevious = &H00000200
Const adAddNew = &H01000400
Const adDelete = &H01000800
Const adUpdate = &H01008000
Const adBookmark = &H00002000
Const adApproxPosition = &H00004000
Const adUpdateBatch = &H00010000
Const adResync = &H00020000
Const adNotify = &H00040000
Const adFind = &H00080000
Const adSeek = &H00400000
Const adIndex = &H00800000

'---- LockTypeEnum Values ----
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4

'---- ExecuteOptionEnum Values ----
Const adRunAsync = &H00000010
Const adAsyncExecute = &H00000010
Const adAsyncFetch = &H00000020
Const adAsyncFetchNonBlocking = &H00000040
Const adExecuteNoRecords = &H00000080

'---- ConnectOptionEnum Values ----
Const adAsyncConnect = &H00000010

'---- ObjectStateEnum Values ----
Const adStateClosed = &H00000000
Const adStateOpen = &H00000001
Const adStateConnecting = &H00000002
Const adStateExecuting = &H00000004
Const adStateFetching = &H00000008

'---- CursorLocationEnum Values ----
Const adUseServer = 2
Const adUseClient = 3

'---- DataTypeEnum Values ----
Const adEmpty = 0
Const adTinyInt = 16
Const adSmallInt = 2
Const adInteger = 3
Const adBigInt = 20
Const adUnsignedTinyInt = 17
Const adUnsignedSmallInt = 18
Const adUnsignedInt = 19
Const adUnsignedBigInt = 21
Const adSingle = 4
Const adDouble = 5
Const adCurrency = 6
Const adDecimal = 14
Const adNumeric = 131
Const adBoolean = 11
Const adError = 10
Const adUserDefined = 132
Const adVariant = 12
Const adIDispatch = 9
Const adIUnknown = 13
Const adGUID = 72
Const adDate = 7
Const adDBDate = 133
Const adDBTime = 134
Const adDBTimeStamp = 135
Const adBSTR = 8
Const adChar = 129
Const adVarChar = 200
Const adLongVarChar = 201
Const adWChar = 130
Const adVarWChar = 202
Const adLongVarWChar = 203
Const adBinary = 128
Const adVarBinary = 204
Const adLongVarBinary = 205
Const adChapter = 136
Const adFileTime = 64
Const adDBFileTime = 137
Const adPropVariant = 138
Const adVarNumeric = 139

'---- FieldAttributeEnum Values ----
Const adFldMayDefer = &H00000002
Const adFldUpdatable = &H00000004
Const adFldUnknownUpdatable = &H00000008
Const adFldFixed = &H00000010
Const adFldIsNullable = &H00000020
Const adFldMayBeNull = &H00000040
Const adFldLong = &H00000080
Const adFldRowID = &H00000100
Const adFldRowVersion = &H00000200
Const adFldCacheDeferred = &H00001000
Const adFldKeyColumn = &H00008000

'---- EditModeEnum Values ----
Const adEditNone = &H0000
Const adEditInProgress = &H0001
Const adEditAdd = &H0002
Const adEditDelete = &H0004

'---- RecordStatusEnum Values ----
Const adRecOK = &H0000000
Const adRecNew = &H0000001
Const adRecModified = &H0000002
Const adRecDeleted = &H0000004
Const adRecUnmodified = &H0000008
Const adRecInvalid = &H0000010
Const adRecMultipleChanges = &H0000040
Const adRecPendingChanges = &H0000080
Const adRecCanceled = &H0000100
Const adRecCantRelease = &H0000400
Const adRecConcurrencyViolation = &H0000800
Const adRecIntegrityViolation = &H0001000
Const adRecMaxChangesExceeded = &H0002000
Const adRecObjectOpen = &H0004000
Const adRecOutOfMemory = &H0008000
Const adRecPermissionDenied = &H0010000
Const adRecSchemaViolation = &H0020000
Const adRecDBDeleted = &H0040000

'---- GetRowsOptionEnum Values ----
Const adGetRowsRest = -1

'---- PositionEnum Values ----
Const adPosUnknown = -1
Const adPosBOF = -2
Const adPosEOF = -3

'---- enum Values ----
Const adBookmarkCurrent = 0
Const adBookmarkFirst = 1
Const adBookmarkLast = 2

'---- MarshalOptionsEnum Values ----
Const adMarshalAll = 0
Const adMarshalModifiedOnly = 1

'---- AffectEnum Values ----
Const adAffectCurrent = 1
Const adAffectGroup = 2
Const adAffectAll = 3
Const adAffectAllChapters = 4

'---- ResyncEnum Values ----
Const adResyncUnderlyingValues = 1
Const adResyncAllValues = 2

'---- CompareEnum Values ----
Const adCompareLessThan = 0
Const adCompareEqual = 1
Const adCompareGreaterThan = 2
Const adCompareNotEqual = 3
Const adCompareNotComparable = 4

'---- FilterGroupEnum Values ----
Const adFilterNone = 0
Const adFilterPendingRecords = 1
Const adFilterAffectedRecords = 2
Const adFilterFetchedRecords = 3
Const adFilterPredicate = 4
Const adFilterConflictingRecords = 5

'---- SearchDirectionEnum Values ----
Const adSearchForward = 1
Const adSearchBackward = -1

'---- PersistFormatEnum Values ----
Const adPersistADTG = 0
Const adPersistXML = 1

'---- StringFormatEnum Values ----
Const adStringXML = 0
Const adStringHTML = 1
Const adClipString = 2

'---- ConnectPromptEnum Values ----
Const adPromptAlways = 1
Const adPromptComplete = 2
Const adPromptCompleteRequired = 3
Const adPromptNever = 4

'---- ConnectModeEnum Values ----
Const adModeUnknown = 0
Const adModeRead = 1
Const adModeWrite = 2
Const adModeReadWrite = 3
Const adModeShareDenyRead = 4
Const adModeShareDenyWrite = 8
Const adModeShareExclusive = &Hc
Const adModeShareDenyNone = &H10

'---- IsolationLevelEnum Values ----
Const adXactUnspecified = &Hffffffff
Const adXactChaos = &H00000010
Const adXactReadUncommitted = &H00000100
Const adXactBrowse = &H00000100
Const adXactCursorStability = &H00001000
Const adXactReadCommitted = &H00001000
Const adXactRepeatableRead = &H00010000
Const adXactSerializable = &H00100000
Const adXactIsolated = &H00100000

'---- XactAttributeEnum Values ----
Const adXactCommitRetaining = &H00020000
Const adXactAbortRetaining = &H00040000

'---- PropertyAttributesEnum Values ----
Const adPropNotSupported = &H0000
Const adPropRequired = &H0001
Const adPropOptional = &H0002
Const adPropRead = &H0200
Const adPropWrite = &H0400

'---- ErrorValueEnum Values ----
Const adErrInvalidArgument = &Hbb9
Const adErrNoCurrentRecord = &Hbcd
Const adErrIllegalOperation = &Hc93
Const adErrInTransaction = &Hcae
Const adErrFeatureNotAvailable = &Hcb3
Const adErrItemNotFound = &Hcc1
Const adErrObjectInCollection = &Hd27
Const adErrObjectNotSet = &Hd5c
Const adErrDataConversion = &Hd5d
Const adErrObjectClosed = &He78
Const adErrObjectOpen = &He79
Const adErrProviderNotFound = &He7a
Const adErrBoundToCommand = &He7b
Const adErrInvalidParamInfo = &He7c
Const adErrInvalidConnection = &He7d
Const adErrNotReentrant = &He7e
Const adErrStillExecuting = &He7f
Const adErrOperationCancelled = &He80
Const adErrStillConnecting = &He81
Const adErrNotExecuting = &He83
Const adErrUnsafeOperation = &He84

'---- ParameterAttributesEnum Values ----
Const adParamSigned = &H0010
Const adParamNullable = &H0040
Const adParamLong = &H0080

'---- ParameterDirectionEnum Values ----
Const adParamUnknown = &H0000
Const adParamInput = &H0001
Const adParamOutput = &H0002
Const adParamInputOutput = &H0003
Const adParamReturnValue = &H0004

'---- CommandTypeEnum Values ----
Const adCmdUnknown = &H0008
Const adCmdText = &H0001
Const adCmdTable = &H0002
Const adCmdStoredProc = &H0004
Const adCmdFile = &H0100
'Const adCmdTableDirect = &H0200

'---- EventStatusEnum Values ----
Const adStatusOK = &H0000001
Const adStatusErrorsOccurred = &H0000002
Const adStatusCantDeny = &H0000003
Const adStatusCancel = &H0000004
Const adStatusUnwantedEvent = &H0000005

'---- EventReasonEnum Values ----
Const adRsnAddNew = 1
Const adRsnDelete = 2
Const adRsnUpdate = 3
Const adRsnUndoUpdate = 4
Const adRsnUndoAddNew = 5
Const adRsnUndoDelete = 6
Const adRsnRequery = 7
Const adRsnResynch = 8
Const adRsnClose = 9
Const adRsnMove = 10
Const adRsnFirstChange = 11
Const adRsnMoveFirst = 12
Const adRsnMoveNext = 13
Const adRsnMovePrevious = 14
Const adRsnMoveLast = 15

'---- SchemaEnum Values ----
Const adSchemaProviderSpecific = -1
Const adSchemaAsserts = 0
Const adSchemaCatalogs = 1
Const adSchemaCharacterSets = 2
Const adSchemaCollations = 3
Const adSchemaColumns = 4
Const adSchemaCheckConstraints = 5
Const adSchemaConstraintColumnUsage = 6
Const adSchemaConstraintTableUsage = 7
Const adSchemaKeyColumnUsage = 8
Const adSchemaReferentialConstraints = 9
Const adSchemaTableConstraints = 10
Const adSchemaColumnsDomainUsage = 11
Const adSchemaIndexes = 12
Const adSchemaColumnPrivileges = 13
Const adSchemaTablePrivileges = 14
Const adSchemaUsagePrivileges = 15
Const adSchemaProcedures = 16
Const adSchemaSchemata = 17
Const adSchemaSQLLanguages = 18
Const adSchemaStatistics = 19
Const adSchemaTables = 20
Const adSchemaTranslations = 21
Const adSchemaProviderTypes = 22
Const adSchemaViews = 23
Const adSchemaViewColumnUsage = 24
Const adSchemaViewTableUsage = 25
Const adSchemaProcedureParameters = 26
Const adSchemaForeignKeys = 27
Const adSchemaPrimaryKeys = 28
Const adSchemaProcedureColumns = 29
Const adSchemaDBInfoKeywords = 30
Const adSchemaDBInfoLiterals = 31
Const adSchemaCubes = 32
Const adSchemaDimensions = 33
Const adSchemaHierarchies = 34
Const adSchemaLevels = 35
Const adSchemaMeasures = 36
Const adSchemaProperties = 37
Const adSchemaMembers = 38

'---- SeekEnum Values ----
Const adSeekFirstEQ = &H1
Const adSeekLastEQ = &H2
Const adSeekAfterEQ = &H4
Const adSeekAfter = &H8
Const adSeekBeforeEQ = &H10
Const adSeekBefore = &H20

'---- ADCPROP_UPDATECRITERIA_ENUM Values ----
Const adCriteriaKey = 0
Const adCriteriaAllCols = 1
Const adCriteriaUpdCols = 2
Const adCriteriaTimeStamp = 3

'---- ADCPROP_ASYNCTHREADPRIORITY_ENUM Values ----
Const adPriorityLowest = 1
Const adPriorityBelowNormal = 2
Const adPriorityNormal = 3
Const adPriorityAboveNormal = 4
Const adPriorityHighest = 5

'---- CEResyncEnum Values ----
Const adResyncNone = 0
Const adResyncAutoIncrement = 1
Const adResyncConflicts = 2
Const adResyncUpdates = 4
Const adResyncInserts = 8
Const adResyncAll = 15

'---- ADCPROP_AUTORECALC_ENUM Values ----
Const adRecalcUpFront = 0
Const adRecalcAlways = 1
%>
---------------------------------------------------------------------------------

另外:
数据库不存在用户即系统设置相关信息,只是搏客文章的标题、内容、及发布时间的几个字段。
2008-05-01 02:25
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
http://www.
在我本地加进CUTSTR没问题,在网上也没问题


<%@ Language=VBScript %>

<!--#include file="Script/adovbs.inc"-->
<%dim view
view=Request.QueryString("view")

'打开数据库
dim objConn, strCon, objRS, strSQL
Set objConn = Server.CreateObject("ADODB.Connection")
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("shujuku\shujuku.mdb")
objConn.connectionstring = strCon
objConn.Open
Set objRS = Server.CreateObject("ADODB.Recordset")
'出现错误重新开始
%>

<html>
<head>
    <title>冷锋博客</title>
    <link rel="stylesheet" type="text/css" href="Script/style.css">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<p>
<div align="center">
<table width="700" border="0" cellpadding="0" cellspacing="0">
    <tr><!--头部-->    
        <td colspan="2" width="700" height="58" align="right" valign="top" background="images/banner.gif">
        <a href="index.asp" title="返回博客首页">博客首页</a>&nbsp;|&nbsp;<a href="javascript:t2s()" style="text-decoration: none">简体</a>&nbsp;|&nbsp;<a href="javascript:s2t()" style="text-decoration: none">繁体</a>&nbsp;|&nbsp;<a href="gbook.asp">留言</a>&nbsp;|&nbsp;<a href="admin.asp">管理</a>&nbsp;</td>
    </tr>
<!--头部结束-->    
    <tr>
        <td width="500" height="100%">
<!--左侧博客文章栏开始-->
            <table width="500" height="100%" border="0" cellpadding="5" cellspacing="0">
                <tr>
                    <td valign="top" width="500" height="100%" class="blog">
<!--首页预览文章-->            <% IF view="" THEN
                            dim counter, blogEntry
                            counter=0
                            ' 设置 SQL 语句从数据库获得信息
                            strSQL="SELECT * FROM TBLBlog WHERE Status=1 ORDER BY id DESC"
                            ' 打开数据库
                            objRS.Open strSQL, objConn, adOpenKeyset, adLockPessimistic, adCmdText
                            %>
                            首页 (最新博客文章预览)
                            <hr size="1" noshade style="color:#000000" width="100%">
                            <%
                            counter=0
                            DO UNTIL counter=7 OR objRS.EOF        '首页显示新文章预览的数目
                            %>
                            <table width="100%" class="blogEntry">
                                <tr>
                                    <td><b><%=objRS("entryTitle")%></b></td>
                                    <td align="right">写于 <%=objRS("byear")%>年<%=objRS("bmonth")%>月<%=objRS("bday")%>日 <%=objRS("btime")%> </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="blog2">
                                    <%blogEntry = cutstr(Replace(objRS("entry"), vbCrLf, "<br>"))
                                    ' 检查输入长度,如果超出必然的字符数就截断
                                    IF Len(blogEntry) > 50 THEN
                                    blogEntry=left(blogEntry,50)
                                    blogEntry=blogEntry+" ......<a href=""index.asp?view=display&ID="&objRS("id")&"""><img src=""images/read.gif"" width=""25"" height=""22"" alt=""阅读全文"" border=""0"" align=""right"" valign=""bottom""></a>"
                                    END IF
                                    Response.Write(blogEntry)
                                    %>
                                    </td>
                                </tr>
                            </table>
                            <br>
                            <%counter=counter+1
                            objRS.MoveNext
                            Loop
                            objRS.Close
                            %>
                            <%END IF%>
<!---显示文章的全文---->
                            <%IF view="display" THEN
                            '显示选定的文章的全文
                            ' 设置 SQL 语句从数据库获得信息
                            strSQL="SELECT * FROM TBLBlog WHERE id="&Request.QueryString("ID")
                            ' 打开数据库
                            objRS.Open strSQL, objConn, adOpenKeyset, adLockPessimistic, adCmdText
                            objRS("bread") = objRS("bread") + 1
                            objRS.Update
                            %>
                        <a href="index.asp" title="博客首页">首页</a>&nbsp;>>&nbsp;阅读博客文章全文
                        <hr size="1" noshade style="color:#000000" width="100%">
                    <table width="100%" class="blogEntry" style="table-layout: fixed;word-wrap:break-word;">
                    <!---防止大图片撑大表格 style="table-layout: fixed;word-wrap:break-word; ---->
                        <tr>
                            <td><b><%=objRS("entryTitle")%></b></td>
                            <td align="right">写于 <%=objRS("byear")%>年<%=objRS("bmonth")%>月<%=objRS("bday")%>日 <%=objRS("btime")%></td>
                        </tr>
                        <tr>
                            <td width="100%" colspan="2" class="blog2" style="word-wrap:break-word;">
                                <P><br>
                                <%
                                blogEntry = cutstr(Replace(objRS("entry"), vbCrLf, ""))
                                Response.Write(blogEntry)
                                %>
                                </P>
                            </td>
                        </tr>
                    </table>
                    <br>
                    <DIV>
                      <div align="right">本文共浏览&nbsp;<%=objRS("bread")%>&nbsp;次&nbsp;</div>
                    </DIV>
                    <br>
                    <%END IF%>
<!---显示显示选定日期的文章---->                    
                    <%
                        IF view="archive" THEN
                        ' 设置 SQL 语句从数据库获得信息
                        strSQL="SELECT * FROM TBLBlog WHERE Status=1 AND bday="&Request.QueryString("day")&" AND bmonth="&Request.QueryString("month")&" AND byear="&Request.QueryString("year")
                        ' 打开数据库
                        objRS.Open strSQL, objConn
                    %>
                    <a href="index.asp" title="博客首页">首页</a>&nbsp;>>&nbsp;查看<%=Request.QueryString("year")%>年<%=Request.QueryString("month")%>月<%=Request.QueryString("day")%>日的博文
                        <hr size="1" noshade style="color:#000000" width="100%">
                    <%
                        IF NOT objRS.EOF THEN
                        DO WHILE NOT objRS.EOF
                     %>
<!--选定日的文章预览表格开始-->    
                            <table width="100%" class="blogEntry">
                                <tr>
                                    <td><b><%=objRS("entryTitle")%></b></td>
                                    <td align="right">写于 <%=objRS("byear")%>年<%=objRS("bmonth")%>月<%=objRS("bday")%>日 <%=objRS("btime")%> </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="blog2">
                                    <%blogEntry = Replace(objRS("entry"), vbCrLf, "<br>")%>
                                    <%' 检查输入长度,如果超出必然的字符数就截断
                                    IF Len(blogEntry) > 35 THEN
                                    blogEntry=left(blogEntry,35)
                                    blogEntry=blogEntry+" ......<a href=""index.asp?view=display&ID="&objRS("id")&"""><img src=""images/read.gif"" width=""25"" height=""22"" alt=""阅读全文"" border=""0"" align=""right"" valign=""bottom""></a>"
                                    END IF
                                    Response.Write(blogEntry)
                                    %>
                                    </td>
                                </tr>
                            </table>
                            <br>
                    <%
                        objRS.MoveNext
                        Loop
                        ELSE
                    %>
                    <br>
                    <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td valign="top">本日无博客文章 ...</td>
                      </tr>
                    </table>
                    <%END IF%>
                    <%END IF%>
<!---显示选定月份的文章---->
                    <% IF view="archiveMonth" THEN
                    '显示选定的日子进入
                    ' 设置 SQL 语句从数据库获得信息
                    strSQL="SELECT * FROM TBLBlog WHERE Status=1AND bmonth="&Request.QueryString("month")&" AND byear="&Request.QueryString("year")&" ORDER BY bday DESC"
                    ' 打开数据库
                    objRS.Open strSQL, objConn%>
                    <a href="index.asp" title="博客首页">首页</a>&nbsp;>>&nbsp;查看<%=Request.QueryString("year")%>年<%=Request.QueryString("month")%>月份的博文
                        <hr size="1" noshade style="color:#000000" width="100%">
                    <%
                    IF NOT objRS.EOF THEN
                    DO WHILE NOT objRS.EOF
                    %>
<!--选定月文章预览表格开始-->    
                            <table width="100%" class="blogEntry">
                                <tr>
                                    <td><b><%=objRS("entryTitle")%></b></td>
                                    <td align="right">写于 <%=objRS("byear")%>年<%=objRS("bmonth")%>月<%=objRS("bday")%>日 <%=objRS("btime")%> </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="blog2">
                                    <%blogEntry = Replace(objRS("entry"), vbCrLf, "<br>")%>
                                    <%' 检查输入长度,如果超出必然的字符数就截断
                                    IF Len(blogEntry) > 35 THEN
                                    blogEntry=left(blogEntry,35)
                                    blogEntry=blogEntry+" ......<a href=""index.asp?view=display&ID="&objRS("id")&"""><img src=""images/read.gif"" width=""25"" height=""22"" alt=""阅读全文"" border=""0"" align=""right"" valign=""bottom""></a>"
                                    END IF
                                    Response.Write(blogEntry)
                                    %>
                                    </td>
                                </tr>
                            </table>
                            <br>
                    <%
                    objRS.MoveNext
                    Loop
                    ELSE
                    %>
<!--没有文章的提示-->                    
                    <br>
                    <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td valign="top">本月无博客文章 ...</td>
                      </tr>
                    </table>
                    <%END IF%>
                    <%END IF%>
                    </td>
                </tr>
          </table>
</td>
<!--左侧栏结束-->    

<!--右侧栏开始-->            
<td width="200" align='center' class="blog3" valign="top"><br>
<!--博客日历开始-->
            <!--#include file="calendar.asp"--><BR>
<!--博客日历结束-->
            <hr size="1" noshade style="color:#915BA3" width="100%">
            <table border="0" width="180" class="blogEntry" cellspacing="0" cellpadding="2">
                <tr>
                    <td align="center" valign="bottom"><b>在线访问计数</b>
                        <hr size="1" noshade style="color:#000000" width="100%">
                            <table border="0" width="90%" cellspacing="0">
                                <tr>
                                    <td><!--#include file="count/count.asp"--></td>
                            </table>
                  </td>
              </tr>
  </table>
            <hr size="1" noshade style="color:##915BA3" width="100%">
            <table width="180" border="0" cellpadding="2" cellspacing="0" class="blogEntry">
                <tr>
                    <td valign="top"><center><b>友情链接</b></center>
                        <hr size="1" noshade style="color:#000000" width="100%">
                            <table width="90%" border="0" cellspacing="0">
                                <tr>
                                    <td width="50%" valign="top">
                                      <div align="center">
                                      &nbsp;●&nbsp; <a href="https://bbs.bccn.net/" target="_blank" class="tiny" title="中国最大的编程者社区">编程论坛</a><BR>
                                      &nbsp;●&nbsp; <a href="http://www. target="_blank" class="tiny" title="图片素材资源网">桌面城市</a><BR>
                                    </td><td width="50%" valign="top">
                                     &nbsp;●&nbsp; <a href="#" target="_blank" class="tiny" title="友情链接">友情链接</a><BR>
                                      &nbsp;●&nbsp; <a href="#" target="_blank" class="tiny" title="友情链接">友情链接</a><BR>
                                       &nbsp;●&nbsp; <a href="#" target="_blank" class="tiny" title="友情链接">友情链接</a><BR>
                                      </div></td>
                                </tr>
                            </table><BR>
                  </td>
              </tr>
  </table>
<BR>

<!--右侧栏结束-->
            </td>
        </tr>
</table>
<BR>
<table width="500" border="0" cellspacing="0" cellpadding="10">
  <tr>
    <td align="center" valign="middle">本站由<a href="http://www. target="_blank"><img src="http://www. border="0" align="absmiddle"></a>&nbsp;&nbsp;提供免费服务</td>
  </tr>
</table>
<BR>
</div>
<!--脚本容错代码-->
<SCRIPT LANGUAGE="JavaScript">
<!--
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>
<!--体部文字简繁转换-->
<script type="text/JavaScript">setFileFileds(document.forms[0].select.value);</script>
</body>
</html>
<!--加载简繁转换脚本-->
<script type="text/JavaScript" language="JavaScript" src="Script/transform.js"></script>
<script type="text/JavaScript" language="JavaScript">
function s2t(){
  document.body.innerHTML=document.body.innerHTML.s2t();
}
function t2s(){
  document.body.innerHTML=document.body.innerHTML.t2s();
}
</script>
<%
Function cutStr(str)
'去掉所有HTML标记
Dim re
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
re.Pattern="<(.[^>]*)>"
str=re.Replace(str,"")
set re=Nothing
Dim l,t,c,i
l=Len(str)
t=0
For i=1 to l
c=Abs(Asc(Mid(str,i,1)))
If c>255 Then
t=t+2
Else
t=t+1
End If

cutStr=str

Next
cutStr=Replace(cutStr,chr(10),"")
cutStr=Replace(cutStr,chr(13),"")
cutStr=Replace(cutStr,chr(32),"")
End Function
%>

2008-05-01 02:34
zslj
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2008-4-28
收藏
得分:0 
不知道 adovbs.inc 文件是干什么的?
但是少了它又不行。
2008-05-01 02:36
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
http://www.
这是在我服务器上测试的

2008-05-01 02:46
zslj
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2008-4-28
收藏
得分:0 
hxfly:
看到了你的测试。
可是问题到底在哪呢?
我只要一用“Function cutStr(str)”这样的语句,就会出现语法错误的提示。
2008-05-01 02:49
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
可能问题出在你的机器吧。我加上了,在我本地测试没错误,在网上测试也没错误,再说,我就没看出来这个方法有错误,不就是一个自定义函数嘛.....

2008-05-01 02:51
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
Function cutStr(str as string)
这样测试一下

2008-05-01 02:53
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
还不行的话我就认输了

2008-05-01 02:54
快速回复:如何加强文章简介的截取功能 (附:解决问题之后的小结)
数据加载中...
 
   



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

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