C# 在关键字where附近获取无效语法

C# 在关键字where附近获取无效语法,c#,asp.net,.net,sql-server-2008,C#,Asp.net,.net,Sql Server 2008,我即将完成一个类似于nike+和runkeeper的网络项目,它是一个公司生产的跑步设备的原型,无论如何,我在这里偶然发现了一个问题,我收到一条错误消息,说关键字WHERE附近的语法无效。我一辈子都想不出来 protected void Page_Load(object sender, EventArgs e) { if (Session["Email"] == null) //If user is not logged in, send to startpage {

我即将完成一个类似于
nike+
runkeeper
的网络项目,它是一个公司生产的跑步设备的原型,无论如何,我在这里偶然发现了一个问题,我收到一条错误消息,说
关键字WHERE附近的语法无效。我一辈子都想不出来

protected void Page_Load(object sender, EventArgs e)
{

    if (Session["Email"] == null) //If user is not logged in, send to startpage
    {
        Response.Redirect("~/UserPages/Default.aspx");
    }
    else if (!IsPostBack) 
    {
        //User info is selected from DB and put in textboxes
        SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["jaklin11ConnectionString"].ConnectionString);
        SqlCommand cmd = new SqlCommand("SELECT * FROM [Users] WHERE Email = @Email", con1);
        cmd.CommandType = CommandType.Text;
        cmd.Parameters.AddWithValue("@Email", Session["Email"].ToString());
        using (con1)
            {
                con1.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.Read())
                    {
                        imgProfileImageProfile.ImageUrl = rdr["ProfileImage"].ToString();
                        textProfileImageProfile.Text = rdr["ProfileImage"].ToString();
                        textFirstNameProfile.Text = rdr["FirstName"].ToString();
                        textLastNameProfile.Text = rdr["LastName"].ToString();
                        textHeightProfile.Text = rdr["Height"].ToString();
                        textWeightProfile.Text = rdr["Weight"].ToString();
                        textPasswordProfile.Text = rdr["Password"].ToString();
                        textBirthdateProfile.Text = rdr["Birthdate"].ToString();
                        textAreaCode.Text = rdr["AreaCode"].ToString();
                        textTown.Text = rdr["Town"].ToString();
                        ddlGenderProfileEdit.Text = rdr["Gender"].ToString();
                    }
            }

    }

}

也许试试[发电子邮件]。同时处理您的SqlDataReader和SqlCommand。@ta.speot.is
Email
不是T-SQL上的一个选项<代码>;)不,仍然得到无效语法…@andrejcurcic请阅读一本关于sql server的书。@andrejcurcic你是认真的吗?正如你所说,你是这门学科的新手,我建议你在开始发展之前读一本关于这方面的好书。我认为建议人们读书没有什么错。。