If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

[RESOLVED] Updating a label on Button Clicks

My application has a simple textbox for user input, a database connection, a button and a label.

I will search for the user input in my database and update the label when the user clicks the button.

This works fine on the first button click but ceases to function on subsequent clicks.

Please check out the attached image to get an overview of what I have. Imagine that a user will enter her/his name in the text box, I will check if the name exists in the database and display it on the label...then the user will enter another name etc...

I would love to learn best practices as well...so please let me know if some of my code should belong in a new code file...in a separate class...maybe I can make use of fewer try-catches etc.

Re: Updating a label on Button Clicks

Have you used the debugger at all? I am betting that the second invocation is throwing an exception and, since you're essentially doing nothing about it and just merrily chuiging along, you don't even notice.

Using Console.WriteLine() in a WinForms app is pretty useless unless you really just want to log to the output window under the IDE.

If you liked my post go ahead and give me an upvote so that my epee.... ahem, reputation will grow.