I couldn't find the syntax error in the following INSERT statement.
public partial class doRegister : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string str = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\database";
using (OleDbConnection con = new OleDbConnection(str))
using (OleDbCommand cmd = con.CreateCommand())
{
cmd.CommandText = "INSERT INTO users (staffID,accessLevelIdD,username,password,email) VALUES (@staffID, '2', @username,@password,@email)";
cmd.Parameters.AddWithValue("@staffID", Request.Form["staffid"]);
cmd.Parameters.AddWithValue("@password",Request.Form["confpassword"]);
cmd.Parameters.AddWithValue("@username", Request.Form["username"]);
cmd.Parameters.AddWithValue("@email", Request.Form["email"]);
con.Open();
try
{
cmd.ExecuteNonQuery();
MessageBox.Show("Successfully registered!");
Response.Redirect("Login.aspx");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
con.Close();
}
}
}
}