Trouble UPDATEing an Access database RRS feed

  • Question

  • User1940910349 posted

    I can SELECT np but I want to UPDATE and it's not working. I don't know if I am using bad code or if Access has some default setting that doesn't let you use UPDATE queries. I did disable the Action Query  check box under options in Access so that I can run the query IN Access.

    Here is my UPDATE code:

        public void UpdateCount(string database, int newCount)
            //Declare and Instantiate a new Database connection and Command variable, as well as a string to hold the command
            System.Data.OleDb.OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + database + "");
            System.Data.OleDb.OleDbCommand command = new OleDbCommand();
            command = conn.CreateCommand();
            string strSQL;

            strSQL = "UPDATE tblCounter SET tblCounter.[Counter] = newCount WHERE(((tblCounter.ID) = 1))";

            command.CommandType = CommandType.Text;
            command.CommandText = strSQL;


    Remember, the SQL works in Access.

    How can I get this to work?


    Wednesday, February 11, 2009 4:59 AM


All replies