Click here to Skip to main content
15,902,634 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to write a generic method where I can send a SQL statement as a parameter and have the statement execute in my Access Database. Have written one that works when all I'm doing is getting information from the database, but I can't seem to get one working that puts information into the database.
SQL = Insert Into [Category] (CategoryDescription) values('Pizza')
And I am getting a "Operation must use an updateable query" error

What I have tried:

public void ExecuteAction(string SQL)
        {
            OpenDatabase();
            OleDbCommand myAccessCommand = new OleDbCommand(SQL, Conn);
            myAccessCommand.ExecuteNonQuery();
            CloseDatabase();
        }

But this doesn't work.
Posted
Updated 19-Jul-17 13:01pm
v2
Comments
CHill60 19-Jul-17 13:45pm    
We need to see the sql

Insert Into [Category] (CategoryDescription) Values('" + txtNewCategory.Text + "')"
 
Share this answer
 
I should mention that I am getting "Operation must use an updateable query" when I run the above code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900