Am trying to insert data into a local database from an asp.net page using the code below but i keep getting this error
"Incorrect syntax near the keyword 'user'"
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> ");
}
}
con.Close()calls, and nocon.Open().