Ошибка в ' cmd. executereader(); '
Я хочу переместить страницу rezomekh. aspx, выбрав запись gridview в коде C#, и получаю ошибку в этой строке:
dr = cmd.ExecuteReader();
а текст ошибки таков:
Incorrect syntax near the keyword 'from'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'from'.
Что я уже пробовал:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { string usnam = e.CommandArgument.ToString(); try { if (e.CommandName == "rezome") { string query = "select from Ordertb where 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"); } } finally { con.Close(); } }