Replace function - error 80020009

S

Séverine Donnay

Hello,

I try to use the replace function with a very long text and I have this
error :

error '80020009'
Exception occurred.

Do you have any idee to resolve this problem ?
Thanks
 
S

Séverine Donnay

I've just use the replace function. If the text is too long, I have the
error but if I cut the text, I don't have any error.

montexte= Replace( montexte, "'", "''" )
 
L

larrybud2002

Séverine Donnay said:
I've just use the replace function. If the text is too long, I have the
error but if I cut the text, I don't have any error.

montexte= Replace( montexte, "'", "''" )

What's the length of the text when there's an error?
 
S

Séverine Donnay

146 800

<[email protected]> a écrit dans le message de (e-mail address removed)...

Séverine Donnay said:
I've just use the replace function. If the text is too long, I have the
error but if I cut the text, I don't have any error.

montexte= Replace( montexte, "'", "''" )

What's the length of the text when there's an error?
 
B

Bob Barrows [MVP]

I've never run into this, so all I can suggest is that you handle the text
in chunks:

dim strlen,ar(),chunk, i
strlen=len(montexte)
if strlen >= <size that causes the error> then
chunk=2000
redim ar(strlen\chunk+ 1)
for i = 0 to ubound(ar)
ar(i)=replace(mid(montexte,i*chunk + 1,chunk),"'","''") next
else
montexte= Replace( montexte, "'", "''" )
end if

It looks like you are processing this string to use it in a dynamic sql
statement. You can avoid this processing by using parameters:
http://groups-beta.google.com/group/microsoft.public.inetserver.asp.db/msg/72e36562fee7804e

Bob Barrows
 
B

Bob Barrows [MVP]

Bob said:
I've never run into this, so all I can suggest is that you handle the
text in chunks:

dim strlen,ar(),chunk, i
strlen=len(montexte)
if strlen >= <size that causes the error> then
chunk=2000
redim ar(strlen\chunk+ 1)
for i = 0 to ubound(ar)
ar(i)=replace(mid(montexte,i*chunk + 1,chunk),"'","''")
next

oops, I forgot the join statement to put the string back together:
montexte=join(ar,"")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top