winforms - VB.NET - Combobox goes blank when a button is clicked, databind doesn't update -
please forgive me, has been time since i've used vb.net may easy.
i have simple login form text box, combobox , button. combobox binded sql database , displays user names users table. idea select name, type in password, , logon new form (this part works great!). if type wrong password, form pops message says "invalid." reason @ stage, combobox goes blank. drop down has empty spaces names once were. typing in name password here results in object reference errors. have tried combo box reset , searched web nothing works!!!
(i know not secure login, easy example of binding data combo box , checking against sql table). help!
enter code here private sub button1_click(sender object, e eventargs) handles btn_logon.click try dim str_user string = users_namecombobox.selectedvalue dim str_pwd string = tb_pwd.text str_user = str_user.trim 'messagebox.show(str_user & "|" & str_pwd)'used verify stage works dim numrecords int16 = userstableadapter.fillbylogin(me.login_testdataset.users, str_user, str_pwd) 'messagebox.show(numrecords) 'used verify stage works if (numrecords > 0) dim db_user string = me.login_testdataset.users(0).users_name.trim dim db_pwd string = me.login_testdataset.users(0).users_pwd.trim 'messagebox.show(db_user & "|" & db_pwd)'used verify stage works if db_user.equals(str_user) , db_pwd.equals(str_pwd) 'user authenticated application 'this section works (removed cleanup code) else messagebox.show("error" & str_user & "|" & str_pwd) 'shows stage works 'need figure out why combobox doesn't refill, using restart 'application.restart() end if end if messagebox.show("error" & str_user & "|" & str_pwd) 'shows stage works 'need figure out why combobox doesn't refill, using restart 'application.restart() catch ex exception messagebox.show(ex.message) 'need figure out why combobox doesn't refill, using restart 'application.restart() end try end sub initializecomponent 'users_namecombobox me.users_namecombobox.databindings.add(new system.windows.forms.binding("text", me.usersbindingsource, "users_name", true)) me.users_namecombobox.databindings.add(new system.windows.forms.binding("selectedvalue", me.usersbindingsource, "users_name", true)) me.users_namecombobox.datasource = me.usersbindingsource me.users_namecombobox.displaymember = "users_name" me.users_namecombobox.name = "users_namecombobox" me.users_namecombobox.valuemember = "users_name"
Comments
Post a Comment