Hi Freinds
below sql query is working nicely when using sql database but with ms acess database this query show msg "
System.Data.OleDb.OleDbException: 'Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.'"
please help me to come out from this issue
- private void btnSAVE_Click(object sender, EventArgs e)
- {
- using (OleDbConnection conn = new OleDbConnection(conString))
- {
- conn.Open();
- OleDbCommand cmd = conn.CreateCommand();
- cmd.CommandType = CommandType.Text;
- cmd.CommandText = "IF EXISTS(select * from tblSUPPLIER where SUPPLIERID='" + txtSUPPLIERID.Text + "') update tblSUPPLIER set [SUPPLIERNAME] = '" + txtSUPPLIERNAME.Text + "' where SUPPLIERID = '" + txtSUPPLIERID.Text + "' ELSE insert into tblSUPPLIER (SUPPLIERNAME) values('" + txtSUPPLIERNAME.Text + "')";
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("Added successfully!");
- }