Visual Basic Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘ADO’

PRB: Error When You Update or Delete New Rows in Access 97 Table

Symptoms
When you use ADO to edit and then update or delete newly added records in a Microsoft Access 97 table, you may receive the following error message when you call the Update method:

Run-time error ‘-2147217864 (80040e38)’:
Row cannot be located for updating. Some values may have been changed since it was last read.This error message may also occur when you edit or delete newly added records in a DataGrid control. The DataGrid control issues an Update behind the scenes when you move to another row.
NOTE: This error does not occur when you edit or delete existing records.
Resolution
The Access 97 table contains an AutoNumber field, and the auto-incremented values of newly added records may not be available for the client recordset. For example, if the AutoNumber field is 5 for the new record in the table, the value of this field in the recordset is always 0. ADO uses this value to locate the record when ADO builds an Update Action Query and sends the value to the Microsoft Jet engine to perform the Update on the specified record. However, the Jet engine cannot locate the record based on that value; thus, you receive the above-mentioned error message.

PRB: Error Assigning Non-Opened Recordset to ADODC

Symptoms
When you attempt to set an ActiveX Data Objects (ADO) Data Control’sRecordset object to a previously dimensioned ADO Recordset the followingerror is returned:

Run-time error ‘3704′:
The operation requested by the application is not allowed if the objectis closed.
Resolution
This error occurs when the recordset has not been opened yet.

PRB: Calculated Field Contents Cannot be Modified by ADO

Symptoms
Trying to modify the contents of a calculated field within an ActiveX Data Objects (ADO) recordset, generates the following error:

Runtime error ‘-2147217887(80040e21)’ errors occurred.
Resolution
Each calculated field in an ADO recordset contains the following attributes:
adFldUnknownUpdatable = False
-and- adFldUpdatable = False This indicates that the field cannot be modified.

PRB: ADO to SQL Server Through ODBC Does Not Support adAsyncFetchNonBlocking When You Use Server-Side Cursors

Symptoms
If you attempt to use ActiveX Data Objects (ADO) to access SQL Server databases through the ODBC provider (MSDASQL), you will receive the following error if you specify adAsyncFetchNonBlocking with Server-side cursors:

-2147217890 lRowsOffset would position you past either end of the rowset, regardless of the cRows value specified; cRowsObtained is 0. The following error is returned from ADO 2.5:

-2147217890 No rows were returned because the offset value moves the position before the beginning or after the end of the rowset.NOTE: If you are using the SQLOLEDB provider you will not see this error message. However, fetching is still not supported for the cursor and it is blocked until the cursor is fully populated.
Resolution
The adAsyncFetchNonBlocking recordset option is not supported with a Server cursor. Additional enhancements would be required for the server and client in order to implement this feature. The two way communication necessary to support adAsyncFetchNonBlocking with a server cursor is not available at this time.

PRB: “Unable to Display Help” or “No Help Available” Error Messages for ADO from Within Visual Basic

Symptoms
When you try to access ActiveX Data Objects (ADO) documentation from within Visual Basic by pressing F1 from the code editor or from within the object browser, nothing occurs, or you receive one of the following error messages:

Unable to display help
-or-

No help available
Resolution
This problem occurs because the following items must exist to access context-sensitive help for ADO in the Visual Basic IDE: The correct version of the ADO compiled HTML help file that corresponds to the ADO version that is referenced in the project references. -and-
An entry in the registry that lists this ADO compiled HTML help file as an available HTML help file. This problem is known to occur when one or both of these items are missing.

PRB: “Operation Must Use an Updateable Query” Error Message When You Access Excel Through ODBC

Symptoms
When you edit an Excel worksheet through ADO and ODBC, you may receive the following error message if you use an ADO DataControl object:

[Microsoft][ODBC Excel Driver] Operation must use an updateable query.If you use a Recordset object that is generated with ADO code, you may receive the following error message when you edit an Excel worksheet through ADO and ODBC:

Run-time error ‘-2147467259(80004005)’:[Microsoft][ODBC Excel Driver] Operation must use an updateable query.
Resolution
This problem occurs if you try to edit a worksheet that is saved or opened as ReadOnly.
NOTE: ReadOnly is the default setting for an ODBC connection to Excel, with or without a data source name (DSN). Therefore, the user must always change that setting to edit data.