02-06-2003 04:24 AM
01-28-2005 03:39 AM
01-28-2005 11:16 AM
01-31-2005 05:05 AM
01-31-2005 09:51 AM
06-02-2005 05:31 AM
06-02-2005 08:57 AM
11-13-2006 05:02 AM
Hello,
Actually, this question is (maybe) not related to datagrid but still to ADO. Retrieving data works fine (using sql SELECT) but when using the sql statement UPDATE to change a value in the database I get an error. The code is like the following:
GetObjHandleFromActiveXCtrl (dbPanel, DB_PANEL_ADODC,&adoHandle);
// sqlStr = “UPDATE table_name SET column_name = new_val WHERE column_name = some_val”;
status = MSAdodcLib_IAdodcSetRecordSource (adoHandle, NULL, sqlStr);status = MSAdodcLib_IAdodcRefresh (adoHandle, &error);
This returns an error “Operation is not allowed when the object is closed”, (status=0x800A0E78). But when reading back from the database the value is changed so the UPDATE statement is correct. Obviously I’m using the wrong methods since I got the same error in Visual C++ when using the same ADO component. I've been looking for any other methods in the fp-files that could be used instead but haven't found anything. Any suggestions?
11-15-2006 11:22 AM
Howdy nweb,
I did some research on Microsoft's website and Google and found several references to the error message you were receiving. That error indicates that the Connection object or Recordset object has been closed. I don't know if you ever created a Connection object or not and if you didn't perhaps that's why you are getting that error.
The first recommendation I would try is inserting the Set Command Type function before the Set Record Source call and test out some of the constants for how the command argument is executed (Documentation can be found here). Secondly, if that has no effect, I would not use the Set Record Set with the UPDATE SQL statement but rather the Connection.Execute method. Set the options parameter on this method to 0x80. This setting indicates that the command text is a command or stored procedure that does not return rows. If any rows are retrieved, they are discarded and not returned. Make sure to open a connection first, then execute, then close. See the remarks section of the MSDN article here.
Hope this helps!