0
Con = new OleDbConnection ();
Con.ConnectionString ="provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\Joker\\Desktop\\LOGIN_DB.mdb";
Con.Open();
Con.Close();

....

private void button1_Click(object sender,EventArgs e)
{
    Con.Open();
    OledbCommand Cmd;
    String query = "INSERT INTO USER (USERNAME, PASSWORD) VALUES ('"+TEXTBOX1.TEXT+"','"+TEXTBOX2.TEXT+"')";
    Cmd= new OledbCommand (query,Con);
    Cmd.ExecuteNonQuery();
    Con. Close();
}
Steve
  • 213,761
  • 22
  • 232
  • 286
Adam
  • 1
  • The duplicate is for MySql but the reason of your error is the same. In your case the reserved word is _Password_ and with MSAccess you use _[Password]_ to let the parser understand your intent to use a column with that name – Steve Jul 07 '22 at 11:11
  • Also it is very important that you don't use string concatenation to build sql commands. You should start to use parameters. They will help you to avoid the Sql Injection hack and will protect you from simple syntax errors like when in your username or password is present a single quote. Try it to see the error. – Steve Jul 07 '22 at 11:14

0 Answers0