...

View Full Version : error '800a0005'



lebronletchev
07-10-2007, 08:18 PM
Hi,

I am with a problem in a script for output data from database:

Error of execution time Microsoft VBScript error '800a0005'

Call of procedure or invalid argument: 'Right'

(sometimes is left)


Someone could help me?

Thanks

Lebron

Daemonspyre
07-10-2007, 08:53 PM
You are probably looking at a NULL (or empty) string, which means that it cannot do the string operator.

Check your output BEFORE the right statement and see if it's empty. If it is, then you may need to do a

if rs("yourData") <> "" then Right(rs("yourData"),5)
if rs("yourData") <> "" then Left(rs("yourData"),5)

lebronletchev
07-10-2007, 09:22 PM
Well,

Although I have written this script sometimes ago I would like you modify it for working well.




<%
'{right*****************************************************************}
myseq = InStr(1, rs.fields("texts"), strKeyword)
leny = len(trim(strKeyword))
lenx = len(trim(rs("texts")))
rightpart = lenX - (myseq +leny)

new = Right(trim(rs("texts")), rightpart)

afterx = InStr(2, trim(new), " ")
plus = Left(new,afterx)
response.write "<font color=red><b>" & trim(plus) & "</b></font>" & "<BR>"

'{1left*****************************************************************}
leftpart = myseq - 1
beforex = Left(trim(rs("texts")), leftpart+1)
left = InStrRev(trim(beforex), " ")
left2 = Mid(beforex,left+1)
strbefore=left(beforeX,left)
response.write StrBefore & "<Br>"
%>

It will output the right and left part of rs("texts").

Thank you

Lebron

Daemonspyre
07-10-2007, 09:33 PM
Can you give me an example of what ORIGINAL rs("texts") is (from the database) and what the output should look like? Also, where/what is strKeyword?

lebronletchev
07-10-2007, 09:55 PM
Are 2 tables - 2 asp files.

test.asp
--------

The user see on the screen all contents of the field "keywords" - keywords are hyperlinks. He click on that and open a new file= results.asp


results.asp
_________
keywords =strkeyword

<%
Dim strKeyword
strKeyword = Request.QueryString("keywords")

rs.open "SELECT * FROM results where TEXTS like '%" & strKeyword & "%' " %>

Example of output of rs("texts")


<A HREF=RESULTS.ASP?keywords=Otawa>Otawa</a>
<A HREF=RESULTS.ASP?Keywords=the>the</a>
city
<A HREF=RESULTS.ASP?Keywords=Canada>Canada</a>



Lebron

Daemonspyre
07-10-2007, 10:44 PM
Ah ha! Gotcha...

Now, one last question (ideas are forming) -- What 'keyword' gets you the MS VBScript error? Any keywords or just one or two?

lebronletchev
07-11-2007, 02:58 AM
Well,

Just one or two, especially when "after" or "before" the keywords there is nothing. As in my example is the keyword is "canada" or "Otawa" I see an error message.


Good luck!

Lebron

lebronletchev
07-16-2007, 07:59 AM
Daemonspyre,

Could you please now give me the results of your "formed ideas".

Thanks

Lebron

Daemonspyre
07-17-2007, 02:25 PM
Sorry bud. Had to run out of town on business unexpectedly... I will have an answer for you shortly.

Daemonspyre
07-17-2007, 03:25 PM
Well, the quick and dirty is that I can make your code a little cleaner, but overall it works very well.

Changes:

1) Don't set a variable unless you are going to use it more than 2 times.

2) Also, your InStr: InStr([start, ]string1, string2[, compare])

You should start you InStr at 0, not 1. If the Keyword is the first word in the rs("texts"), then you will receive a NULL result.



<%
'{right*****************************************************************}
myseq = InStr(0, rs("texts"), strKeyword) 'CHANGED InSTR
rightpart = len(trim(rs("texts"))) - (myseq + len(trim(strKeyword)))
new = Right(trim(rs("texts")), rightpart)
plus = Left(new,InStr(1, trim(new), " ")) 'CHANGED InSTR
response.write "<font color=red><b>" & trim(plus) & "</b></font>" & "<BR>"

'{left*****************************************************************}
leftpart = myseq - 1
beforex = Left(trim(rs("texts")), leftpart+1)
strbefore=left(beforeX,InStrRev(trim(beforex), " "))
response.write StrBefore & "<Br>"
%>


Lastly, it looks as though you are, by the code above, setting the Keyword = RED. You can also do this in JavaScript. However, why fix it if it isn't broken?

You did a good job here!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum