我试图插入文本框值,但它会一直显示' USER附近的语法错误?

时间:2016-04-10 08:57:49

标签: c# web sql-insert executenonquery

protected void SubmitButton_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename= C:\Users\HP\documents\visual studio 2010\Projects\WebApplication2\WebApplication2\App_Data\eguidance.mdf;Integrated Security=True;User Instance=True");
        {

            SqlCommand sm = new SqlCommand( "Insert into USER ( email_address , first_name , last_name, ssn , password ) values ( @E_add, @f_name, @l_name ,@ssn , @pass )", con);
            sm.Parameters.AddWithValue("@E_add", E_add.Text);
            sm.Parameters.AddWithValue("@f_name", f_name.Text);
            sm.Parameters.AddWithValue("@l_name", l_name.Text);
            sm.Parameters.AddWithValue("@ssn", ssn.Text );
            sm.Parameters.AddWithValue("@pass", pass.Text );

            con.Open();
            sm.ExecuteNonQuery();
            con.Close();


        }

0 个答案:

没有答案