c# - error on cmd.ExecuteReader(); -


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

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -