我正在尝试使用下面的代码从 asp.net 页面将数据插入本地数据库,但我不断收到此错误
“关键字‘用户’附近的语法不正确”
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString);
con.Close();
string inse = "insert into user (username, password, emailadd, fullname, country) values(@username, @password, @emailadd, @fullname, @country) ";
SqlCommand insertuser = new SqlCommand(inse, con);
insertuser.Parameters.AddWithValue("@username",TextBoxFA.Text);
insertuser.Parameters.AddWithValue("@password", TextBoxEA.Text);
insertuser.Parameters.AddWithValue("@emailadd", TextBoxRPW.Text);
insertuser.Parameters.AddWithValue("@fullname", TextBoxPW.Text);
insertuser.Parameters.AddWithValue("@country",DropDownList1.SelectedItem.ToString());
try
{
insertuser.ExecuteNonQuery();
con.Close();
Response.Redirect("login.aspx");
}
catch (Exception ex)
{
Response.Write("<b>something really bad happened.....Please try again</b> ");
}
}