none
[MS Access & VC++] Updateable Query Error RRS feed

  • Question

  • This post is similar to Troubled Soul's thread on "Operation needs updateable query error 3073". I have two types of database connections: oldConnection and newConnection (based from OleDbConnection).

    When I first create a connection with the oldConnection, an *.ldb (record-locking file) appears on the oldConnection's database file. A problem occurs when I try to create a second connection with the newConnection. Even if I was successfull in creating a connection with the newConnection, the *.ldb file does not appear for newConnection, which I suspect is the reason why I cannot do any INSERT/DELETE queries to the newConnection.

    I tried closing the old connection by using Close and Dispose functions but it still did not work. The newConnection's database has read/write property (which I kept on reading from various ASP support forums). Also, these 2 databases (old and new) are found in my local computer only.

    Thanks in advance.
    Friday, July 13, 2007 7:18 AM

All replies

  • Do you get exact same error message?
    Friday, July 13, 2007 10:44 AM
    Moderator

  • So just to confirm, you're opening two different Access database files using two different Connection objects? Are the database files in the same folder? Do they have different names?
    Friday, July 13, 2007 12:50 PM
  • VMazur: Yes, I also get the same error message and error code (3073).
    Friday, July 13, 2007 2:37 PM
  • Paul: Yes, I am opening two different Access database files using two different Connection objects. These databases have different filenames and I tried accessing them in different/same folder but I still get an error message.
    Friday, July 13, 2007 2:39 PM

  • Could you post a snippet of code that reproduces the error?
    Friday, July 13, 2007 3:25 PM
  • Paul: Sure! Here is the code. Also, I have updated the oldConnection to myConnection instead.

    /*
     * (1) Checks if the database for the new connection exists.
     * (2) If new database exists, proceeds to perform some INSERT and DELETE queries to the
     * current connection
    (myConnection).
     * (3) After the updates are made to the current connection, closes down the current connection.
     * (4) Current connection takes the new connection.
     * (5) INSERT queries are made to the NEW (current) myConnection Smile
     */

    void ChangeDatabase(String * myDataSource, String * newDataSource)
    {
         // Connection String
         String * connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";

         // The myDataSource and newDataSource indicates the path of the Access database files.
         myConnectionString = String::Concat(connectionString, myDataSource);
         newConnectionString = String::Concat(connectionString, newDataSource)

         // OleDbConnection object (current)
         OleDbConnection * myConnection = new OleDbConnection(myConnectionString);

         // OleDbConnection object (new)
         OleDbConnection * newConnection = new OleDbConnection(newConnectionString);

         try
         {
              // Establish Database Connection (current)
             // .ldb file appears for myConnection
              myConnection->Open();

             // Establish Database Connection (new)
             // .ldb file does not appear for newConnection
              // I can leave this connection open so that I won't have to open it twice Smile
             newConnection->Open();

              // In the meantime, I will close the newConnection for now.
             // Close new connection.
             if (newConnection->State != ConnectionState::Closed)
              {
                   newConnection->Close();

                  // I tried adding Dispose here as well.
                  ...
             }

              // INSERT and DELETE queries can be made to the current connection (myConnection).
              ...

              // After the INSERT and DELETE queries, current connection can now be closed.
              // Close current connection.
              if (myConnection->State != ConnectionState::Closed)
              {
                   myConnection->Close();

                   // I tried adding Dispose here as well.
                   ...
              }

             // Establish Database Connection (new)
             // .ldb file does not appear for newConnection
              // I just opened the new connection again.
             newConnection->Open();

              // INSERT queries should be made to the new connection (newConnection).
              // But the error occurs here when I try to include several INSERT queries to the new
              // connection (newConnection).
              ...

              // After the INSERT queries in the new connection, I will set the currentConnection to the
              // newConnection.
              myConnection = newConnection;
              myConnection->Open();
         } catch (Exception * error) {
              MessageBox:: Show(error->Message);
         }
    }

    Monday, July 16, 2007 1:52 AM