vb.net - vb 2010 InvalidCastException error -
i trying create simple access db login form , have received error above when running. happens if user combo correct. if login incorrect, invalid message shown. if supply correct credentials error thrown. can enlighten me error means. mentions 'conversion string "bt" type 'boolean' not valid.' 'bt' correct username.
private sub login_click(byval sender system.object, byval e system.eventargs) handles btnlogin.click ' if txtlogin.text = "1" , txtpassbox.text = "1" ' form2.show() ' me.hide() ' else : msgbox("sorry, combination not recognised.", msgboxstyle.critical, "invalid data supplied") ' end if dim user string dim password string user = txtlogin.text password = txtpassbox.text if me.usertableadapter.scalarquerylogin(user, password) messagebox.show("you have logged in") else messagebox.show("you have supplied wrong combo") end if end sub sql query:
select [user], [password] [user] ([user] = ?) , ([password] = ?)
it looks scalarquerylogin method returns string, , using if boolean.
edit: easier troubleshoot if told type scalarquerylogin method returns. anyways, try this:
private sub login_click(byval sender system.object, byval e system.eventargs) handles btnlogin.click ' if txtlogin.text = "1" , txtpassbox.text = "1" ' form2.show() ' me.hide() ' else : msgbox("sorry, combination not recognised.", msgboxstyle.critical, "invalid data supplied") ' end if dim user string dim password string user = txtlogin.text password = txtpassbox.text if me.usertableadapter.scalarquerylogin(user, password) isnot nothing messagebox.show("you have logged in") else messagebox.show("you have supplied wrong combo") end if end sub
Comments
Post a Comment