I can't connect to my SQL Server database Using VB.NET -
protected sub login_btn_click(sender object, e eventargs) handles login_btn.click dim connstring string dim connection sqlconnection dim command sqlcommand dim sql string connstring = "data source=.\sqlexpress;initial catalog=suivi_invst;integrated security=true" sql = "select net_id, password user" connection = new sqlconnection(connstring) try connection.open() command = new sqlcommand(sql, connection) dim sqlreader sqldatareader = command.executereader() while sqlreader.read() if (password.text = sqlreader("password") , net_id.text = sqlreader("net_id")) response.redirect("creation.aspx") end if end while sqlreader.close() command.dispose() connection.close() catch ex exception msgbox("can not open connection ! ") end try end sub
i msg box saying connection can noy established.
i tried open sql server management studio @ same time code running didn't anything.
from exception text:
incorrect syntax near keyword 'user'
user
reserved keyword in sql server.
basically not recommended create table having name equals reserved keywords, if need name, have surround square brackets in query this:
select net_id, password [user]
Comments
Post a Comment