Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
MonthlyLeaders
ASK A QUESTION
Forumguidelines
Ashfaque Baig
1.9k
66
940
Sql query not working with MS Access 2007 database
May 10 2020 11:04 AM
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!"
);
}
Reply
Answers (
1
)
Data parse Form to UserControl?
invoking methods inside other method