html - Connecting to database and reading data in asp.net -
what doing wrong here? error:
incorrect syntax near =
on line of code:
dim sqldatareader sqlclient.sqldatareader = sqlcommad.executereader()
my code:
dim username = tusername.text dim password = tpassword.text dim sqlconnection = new sqlclient.sqlconnection(my.settings.dbconnection.tostring) dim sqlcommand = new sqlclient.sqlcommand("select * " + my.settings.tablename.tostring + "where empid = " + username, sqlconnection) sqlconnection.open() dim sqldatareader sqlclient.sqldatareader = sqlcommand.executereader while (sqldatareader.read) if username = sqldatareader(1).tostring , password = sqldatareader(20).tostring if eencrypt(username, password) msgbox("you not logged in") else msgbox("you logged in") end if end if end while sqlconnection.close()
this should work, see how parammeter added
dim username = tusername.text dim password = tpassword.text dim sqlconnection = new sqlclient.sqlconnection(my.settings.dbconnection.tostring) dim sqlcommand = new sqlclient.sqlcommand("select * " + my.settings.tablename.tostring + "where empid = @username", sqlconnection) sqlcommand.parameters.addwithvalue("@username", username) sqlconnection.open() dim sqldatareader sqlclient.sqldatareader = sqlcommand.executereader() while (sqldatareader.read) if username = sqldatareader(1).tostring , password = sqldatareader(20).tostring if eencrypt(username, password) msgbox("you not logged in") else msgbox("you logged in") end if end if end while sqlconnection.close()
Comments
Post a Comment