Help with avoiding error message


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?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.
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
     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

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:

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

Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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.
vcharlesAuthor Commented:
vcharlesAuthor Commented:
Thank you
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.