Ron Allen

Ron Allen

  • NA
  • 9
  • 5k

Real-time search using TextBox/Out of Memory Errors

Mar 13 2012 4:59 PM
Visual Studio 2003 and SQL Server 2000 (yes, I know).

I have a Windows Forms program where I want to update an information display from a SQL Server 2000 database in real-time based on what the user types into a text box.

What I've done is essentially put the dataset refresh code in the text_changed event of the text box. I clear the dataset, get the new string to match against from the textbox, , set the parameter value in the data adapter, and fill the dataset. The display fields are labels with their text bound to the dataset fields. So when the user starts typing in a name, for example, with each letter typed the dataset is refreshed, showing only matches. I use a "LIKE" clause in the SQL to match on the data.

The actual code is more complex than that implies, as it makes calls to other places to get and format the search strings, and results are further filtered on other conditions such as radio buttons or check boxes, but that's the basic concept.

This seems to work fine, except after a relatively short time in use the program will crash with an unhandled Out of Memory error (my code includes error handling, which tells me and logs where the error occurred, but this exception is not getting handled).

What am I doing wrong, or what is the preferred way to implement this?

Thanks,

Ron




Answers (8)