The whole idea is that I have a register form and after filling all fields with data(Username, Email and Password) and press the Register button to insert this data into my Access database and make a new record but when i try to do so it show Syntax INSERT INTO Error.
Here is the database insert code:
OleDbCommand command = new OleDbCommand();
command.CommandType = System.Data.CommandType.Text;
command.CommandText = "INSERT INTO Users (Username, Email,
Password)" + " VALUES (@Username,@Email,@Password)";
command.Parameters.AddWithValue("@Username",
regUsername.Text);
command.Parameters.AddWithValue("@Email", regEmail.Text);
command.Parameters.AddWithValue("@Password",
regPassword.Text);
command.Connection = dbConnection;
dbConnection.Open();
command.ExecuteNonQuery();
dbConnection.Close();
And here is the exception:
************* Exception Text **************
System.Data.OleDb.OleDbException (0x80040E14): Syntax error in INSERT INTO statement. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
enter code here
dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at uLock.Register_Design.label1_Click(Object sender, EventArgs e) in C:\Users\NyonBG\Desktop\uLock\uLock\Register Design.cs:line 200 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Label.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
User contributions licensed under CC BY-SA 3.0