I've got an error message:
System.Data.OleDb.OleDbException: 'Syntax error in INSERT INTO statement.'
I've read through multiple questions like this, but non of their answers helped me.
This is my code:
conn.Open();
string sql = "";
sql = "insert into player(Username, Password) values(@Username, @Password)";
using (command = new OleDbCommand(sql, conn))
{
command.Parameters.AddWithValue("@Username", textBoxUsername.Text);
command.Parameters.AddWithValue("@Password", textBoxPassword.Text);
command.ExecuteNonQuery();
}
command.Dispose();
conn.Close();
The error is in the following line:
command.ExecuteNonQuery();
Does anyone know a solution for this error?
Thanks in advance!
values(?, ?)syntax.SqlConnection/SqlCommandetc for SQL Server. This will allow you to use that target database's full set of features, such as named parameters. OleDb is quite... well, minimal, frankly. It doesn't support named parameters, as noted by the existing answer etc.