con.Open();
cmd = new OleDbCommand("insert into login (user, password) values ('" +textBox1 .Text + "','" + textBox2 .Text + "');",con);
cmd.CommandType = CommandType.Text;
int temp = cmd.ExecuteNonQuery();
if (temp > 0)
{
textBox1.Text = null;
textBox2.Text = null;
MessageBox.Show("Record Successfuly Added");
}
else
{
MessageBox.Show("Record Fail to Added");
}
con.Close();
when i try to insert some of error appear ( syntax error in INSERT STATEMENT ) i'm try different method to values like Parameters or direct plz !
Login,userandpassword, trying putting square brackets[]around them and execute the same query again.textBox1.Text = string.Emptyinstead oftextBox1.Text = null. 2) You can close the connection right after query execution (int temp = cmd.ExecuteNonQuery(); con.Close();).