c# - error on cmd.ExecuteReader(); -
this question has answer here:
i want move rezomekh.aspx page choosing record of gridview in c# code, here code:
protected void gridview1_rowcommand(object sender, gridviewcommandeventargs e) { string usnam = e.commandargument.tostring(); try { if (e.commandname == "rezome") { string query = "select ordertb username=@username"; sqlcommand cmd = new sqlcommand(query, con); cmd.parameters.addwithvalue("@username", usnam); con.open(); sqldatareader dr; dr = cmd.executereader(); dr.read(); session["usernamekh"] = dr["username"].tostring(); //viewstate["userid"] = usid; cmd.executenonquery(); con.close(); response.redirect("rezomekh.aspx"); } } { con.close(); } } and error on line:
dr = cmd.executereader(); and error text is:
incorrect syntax near keyword 'from'. description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code. exception details: system.data.sqlclient.sqlexception: incorrect syntax near keyword 'from'.
Comments
Post a Comment