Help with avoiding error message

Hi,

When running a query with multiple OR statements (VB.NET) containg a very long search string, I teceive the following  error message,  "System.StackOverFlowException' occured in System.Data.dll"

How do I avoid this error?

Victor
vcharlesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
You have probably made a mistake somewhere in the string.  Check it for correctness.
0
Jacques Bourgeois (James Burger)PresidentCommented:
You might replace some or all of the OR instructions with IN. Instead of
     Data=1 OR Data=2 OR Data=4
try
     Data IN(1,2,4)

If this does not work, you might want to give a look at the following:

Stack overflow occurs when you run a query that contains a large number of arguments inside an IN or a NOT IN clause in SQL Server

FIX: A stack overflow exception may occur, and SQL Server 2000 may unexpectedly close when you submit a query that uses the UNION ALL operator more than 255 times
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vcharlesAuthor Commented:
Hi

It wotks with IN (1,2,3). Is there s maximum size allowed using IN ()?

Thanks,
Victor
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Jacques Bourgeois (James Burger)PresidentCommented:
Nothing specified in the documentation.

As shown in the first of the 2 links I sent you, there was a bug if IN became too big in SQL Server 2000. I supposed it has been corrected if you are using a newer versions.
0
vcharlesAuthor Commented:
Thanks.
0
vcharlesAuthor Commented:
Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.