关于无效使用 Null: 'Replace'

使用REPLACE来将数据库里读出来的数据替换,如果字段不为空是正常,但如果
为空时就出现以下提示:
Microsoft VBScript 运行时错误 错误 '800a005e' 
无效使用 Null: 'Replace' 

可以先判断
if isnull(rs("coutent"))=false then
response.write("null") 
else
response.write replace(rs("coutent"),chr(13),"<br/>")
end if

展开阅读全文

急求无效使用 Null: 'Replace'的解决办法

09-16

以下是程序代码 rn<% rn'新闻排行 rn'ClassID类别ID rn'NewNum新闻条数 rn'TitleLen标题字符长度 rn'OrderType排序类型:0-日排行,1周排行,2月排行 rnsub NewsListOrderBy(ClassID,NewNum,TitleLen,OrderType) rndim whereString rnsql = "select top " & NewNum & " htmlPath,title,Hits from ["& Cfg.tablePrefix &"news]" rnif ClassID = "" then rn sql = sql & " where isRec = 0 and isSign = 1" rnelse rn sql = sql & " where classId = " & ClassID & " and isRec = 0 and isSign = 1" rnend if rnSelect Case OrderType rn Case 0 rn whereString = "and datediff(hour,createDate,getDate()) < 24" rn Case 1 rn whereString = "and DATEPART(wk, createDate) = DATEPART(wk, GETDATE()) and DATEPART(yy, createDate) = rnrnDATEPART(yy, GETDATE())" rn Case 2 rn whereString = "and datediff(m,getdate(),createDate)=0" rnEnd Select rnsql = sql & whereString rnsql = sql & " order by Hits desc" rnrs = dbo.query(sql) rnif isnull(rs) or isempty(rs) then rn response.Write("暂无数据") rnelse rn for i = 0 to ubound(rs,2) rn htmlPath = rs(0,i) rn title = rs(1,i) rn Hits = rs(2,i) rn[color=#FF0000](错误行) htmlPath = replace(htmlPath,"/news/","") [/color]rnrnrn %> rn rn rn <% = rnrnlib.cut_Title(title,TitleLen) %> rn <% = Hits %> rn rn<% rn next rnend if rnset rs = nothing rnend sub rn%> rnrn在站里也看了相关的帖子,但本人asp水平有限,具体的如何解决还请各位老师多多帮助,在这里谢过大家了。 论坛

无效使用null的问题

05-21

实时错误:94 无效使用nullrn代码:rn[code=VB]Private Sub Form_Load()rnDim a As StringrnDim rs1 As New ADODB.RecordsetrnDim rs2 As New ADODB.Recordsetrna = "provider=Microsoft.jet.OLEDB.4.0;Data source=" & App.path & "\jf.mdb;persist security info=false"rnconn1.CursorLocation = adUseClientrnconn1.Open arna = "select cardid as 卡号,studentid as 学号,roomid as 机房号,computerid as 机器号,teacher as 值班老师, starttime as 上机时间,endtime as 下机时间,statue as 状态,bz as 备注 from recording where endtime is null"rnrs1.Open a, conn1, adOpenKeyset, adLockPessimisticrnSet DataGrid1.DataSource = rs1rnDataGrid1.Refreshrna = "select cardid as 卡号,studentid as 学号,roomid as 机房号,computerid as 机器号,teacher as 值班老师, starttime as 上机时间,endtime as 下机时间,statue as 状态,bz as 备注 from recording where endtime is not null"rnrs2.Open a, conn1, adOpenKeyset, adLockPessimisticrnSet DataGrid2.DataSource = rs2rnDataGrid2.RefreshrnEnd SubrnrnPrivate Sub Form_Unload(Cancel As Integer)rnconn1.ClosernSet conn1 = NothingrnEnd SubrnrnPrivate Sub Timer1_Timer()rnDim a As StringrnDim b As DaternDim rs1 As New ADODB.RecordsetrnDim rs2 As New ADODB.RecordsetrnDim rs3 As New ADODB.Recordsetrna = "select * from recording where endtime is null"rnrs1.Open a, conn1, adOpenKeyset, adLockPessimisticrnIf rs1.EOF = True And rs1.BOF = True Thenrn Exit SubrnEnd Ifrnrs1.MoveFirstrna = "select cardid as 卡号,studentid as 学号,roomid as 机房号,computerid as 机器号,teacher as 值班老师, starttime as 上机时间,endtime as 下机时间,statue as 状态,bz as 备注,usetime as 上机用时 from recording where endtime is null"rnrs3.Open a, conn1, adOpenKeyset, adLockPessimisticrnrnWhile Not rs1.EOFrn If rs1.Fields(10) = "" Thenrn rs1.Fields(10) = rs1.Fields(5)rn rs1.Updatern Elsern b = Format(rs1.Fields(10), Now)rn str1 = DateDiff("n", b, Now())rn rs1.Fields(10) = Now()rn rs1.Fields(9) = str1rn rs1.Updatern If str1 >= 1 Thenrn a = "select * from card where cardid='" + rs1.Fields(0) + "'"rn rs2.Open a, conn1, adOpenKeyset, adLockPessimisticrn rs2.Fields(1) = rs2.Fields(1) - 1rn rs2.Updatern End Ifrn rs1.MoveNextrn End IfrnWendrnrs2.MoveFirstrnWhile Not rs2.EOFrn If rs2.Fields(1) <= 0 Thenrn Label5.Caption = "成功"rn rs2.MoveNextrn End IfrnWendrnrnSet DataGrid1.DataSource = rs3rnDataGrid1.Refresh[/code] 论坛

没有更多推荐了,返回首页