asp.net - What is wrong with my this code, i think the select query is wrong? -


what wrong code, think select query wrong :

i have textbox1, textbox2 , textbox3

when type employee id in textbox1 , email in textbox2 in textbox3 password retrieved according employee id , email in database...

protected sub button1_click(byval sender object, byval e system.eventargs) handles button1.click             'dim cmdselect new system.data.sqlclient.sqlcommand("select password a1_admins employeeid" = textbox1.text , "email" = textbox2.text, sqldata)             dim sqldata new system.data.sqlclient.sqlconnection("data source=.\sqlexpress;attachdbfilename=|datadirectory|\aspnetdb.mdf;integrated security=true;user instance=true")             dim cmdselect new system.data.sqlclient.sqlcommand("select password a1_admins employeeid =" & textbox1.text & "and" & "email" = textbox2.text, sqldata)             sqldata.open()             dim dtrreader system.data.sqlclient.sqldatareader = cmdselect.executereader()             if dtrreader.hasrows                 while dtrreader.read()                     textbox3.text = dtrreader("password")                 end while             else                 textbox3.text = ("no customer found supplied id.")             end if              dtrreader.close()             sqldata.close()         end sub 

it have been useful if had posted actual error message.

however, think sql query missing spaces. should be:

dim cmdselect new system.data.sqlclient.sqlcommand("select password a1_admins employeeid = " & textbox1.text & " , " & "email = '" & textbox2.text & "'", sqldata)

edit

as pointed out in other answers should using parameters. have provided link msdn article on using parameters sqlcommand class


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -