Execute your procedure in the
Validated
event handler, rather than in the
TextChanged
one; as you already have been told, recreating a DB connection and query everytime a new character is entered in a TextBox is a design issue, it will make your application less responsive and annoying, from a user experience point of view.
You should also avoid constructing SQL queries by concatenating values obtained from users; this leaves your code opened to SQL injection attacks.
For example, if anyone enters the following text in
textBox1
:
';DROP DATABASE ParamBills;--
then you're busted.
Regards.