asp提示無效使用?Null:?Replace的解決方法
asp下載使用REPLACE來將數(shù)據(jù)庫里讀出來的數(shù)據(jù)替換,如果字段不為空是正常,但如果為空時(shí)就出現(xiàn)以下提示:
Microsoft VBScript 運(yùn)行時(shí)錯(cuò)誤 錯(cuò)誤 '800a005e'
無效使用 Null: 'Replace'
主要問題就是sqlserver的字段為null,所以不能簡單的為空判斷,只能使用isnull
可以先判斷
if isnull(rs("coutent"))=false then
response.write("null")
else
response.write replace(rs("coutent"),chr(13),"")
end if或者
if rs("coutent")="" then
response.write("null")
else
response.write replace(rs("coutent"),chr(13),"")
end if測試:
if isnull(keyword)=true then keyword=dxy_title
if isnull(descriptions)=true then descriptions=dxy_title
asp replace函數(shù)
Replace語法
Replace(expression, find, replacewith[, compare[, count[, start]]])
Replace 函數(shù)參數(shù)
expression:必選。 字符串表達(dá)式 包含要替代的子字符串。
find: 必選。被搜索的子字符串。
replacewith :必選。用于替換的子字符串。
start: 可選。expression 中開始搜索子字符串的位置。如果省略,默認(rèn)值為 1。在和count 關(guān)聯(lián)時(shí)必須用
count :可選。執(zhí)行子字符串替換的數(shù)目。如果省略,默認(rèn)值為 -1,表示進(jìn)行所有可能的替換。在和 start 關(guān)聯(lián)時(shí)必須用。
compare: 可選。指示在計(jì)算子字符串時(shí)使用的比較類型的數(shù)值。有關(guān)數(shù)值,請參閱“設(shè)置”部分。如果省略,缺省值為 0 ,這意味著必須進(jìn)行二進(jìn)制比較。
設(shè)置
compare 參數(shù)可以有以下值:
常數(shù) 值 描述
vbBinaryCompare 0 執(zhí)行二進(jìn)制比較。
vbTextCompare 1 執(zhí)行文本比較。
下面一個(gè)就是替換“'”為“''”
Function strReplace(Str) dim tempcheckstr tempcheckstr=Str If Isnull(tempcheckstr) Then strReplace = ""http://這里要注意,如果字符串為空,那replace裝會(huì)出錯(cuò) Exit Function End If strReplace = Replace(tempcheckstr,"'","''") End Function
到此這篇關(guān)于asp提示無效使用 Null: Replace的文章就介紹到這了,更多相關(guān)Null Replace內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
在asp中通過vbs類實(shí)現(xiàn)rsa加密與解密的代碼
在asp中通過vbs類實(shí)現(xiàn)rsa加密與解密的代碼...2007-03-03
ASP+Access數(shù)據(jù)庫安全設(shè)置方法小結(jié)
Access數(shù)據(jù)庫安全設(shè)置方法小結(jié)2008-12-12
ASP中字符與數(shù)字內(nèi)置操作函數(shù)整理
在ASP中,預(yù)定義了許多函數(shù),可以幫助我們簡化代碼、提高開發(fā)效率,本文將介紹一些常用的ASP字符與數(shù)字內(nèi)置操作函數(shù),以便開發(fā)人員更加方便、快速地創(chuàng)建 Web 應(yīng)用程序,2023-12-12

