vb.net - How to check if string a exists in a specified column in database -


this sample access database:

id--username--password--accounttype

1---- a123 --1234 --user

2-----b123 --1345 --admin


i using vs2012. in vb.net project have username textbox, password textbox, , login button.

i add database using wizard. can add, modify, delete, , query, how check if entered username in username text box exists in username column?

i filled dataset using:

me.userstableadapter.fill(me.wsdataset.users) 

and if want user type using:

me.wsdataset.users.findbyusername(idtxt.text).acounttype 

but main problem if user not exists error below:

an unhandled exception of type 'system.nullreferenceexception' occurred in user login.exe additional information: object reference not set instance of object.

how can check if username exists or not?

try doing this.

 dim user = me.wsdataset.users.findbyusername(idtxt.text)   if not user nothing      'do want user object  else      'message user not exist.  end if 

you check if user exists want it.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -