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 ‘activex data objects’

BUG: Error “Row Cannot Be Located for Updating” If You Change Numeric Field in ADODC Recordset

Symptoms
If an ActiveX Data Objects data control (ADODC) is bound to a Microsoft Access table that specifies a default value for the numeric field, when you take the following actions:Add a new record to the ADO recordset, which the ADODC exposes, without entering a value for that numeric field.Update the recordset.Type a value into the numeric field (either directly into the Recordset field or into the corresponding DataGrid cell) in that same newly-added record.Update the recordset again.the following run-time error is raised with error number -2147217864 (80040e38) or 6153:

Row cannot be located for updating. Some values may have changed since it was last read.If a DataGrid control is bound to the ADODC, the same error message usually appears a second time without an error number in a dialog box that is entitled “Microsoft DataGrid Control.”
Resolution
To resolve this problem, remove the default value that is specified for the numeric field in the Access database table.
Alternately, you can run an UPDATE statement on a separate ADO Connection object to update the numeric field in the newly-added record directly in the database and then refresh the ADODC.

PRB: Improper Installation of MDAC May Return Error Message “Method ‘~’ of Object ‘~’ Failed” at Run Time with ADO Application

Symptoms
When you attempt to run simple ActiveX Data Objects (ADO) code in an application, the following error can occur:

“Method ‘~’ of Object ‘~’ Failed”
Resolution
The most common cause for this error is mismatched DLL files with Microsoft Data Access Components (MDAC).

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: Error “Unrecognized Database Format” When You Upgrade to Access 2000 or 2002

Symptoms
If you try to gain access to an Access 2000 or Access 2002 database, you may receive one of the following errors within your Visual Basic program.
If you are using Microsoft ActiveX Data Objects (ADO) (or the ADO Data Control), you receive the following error message:

Run-time error -2147467259 Unrecognized Database Format XXXIf you are using Data Access Objects (DAO) (or the DAO generic Data Control), you receive the following error message:

Run-time error 3343 Unrecognized Database Format XXX
Resolution
Access 2000 and Access 2002 use the Jet 4.0 engine, which creates Jet 4.0 format database files. Jet 3.5 components do not recognize such a format.If you are using ADO, you get error -2147467259 when you try to connect to your Access 2000 or 2002 database through the Microsoft.Jet.OLEDB.3.51 provider.If you are using DAO, you get error 3343 when you use the Microsoft DAO 3.51 Object Library.The DAO generic Data Control does not work against Access 2000 or 2002 databases and always generates error 3343 unless it is used as instructed in the “Resolution” section of this article. This occurs because this control is based on Jet 3.51 and only recognizes Jet 3.51 (or before) database formats.

PRB: Error “Syntax Error Near ‘Tablename’” on Recordset Update

Symptoms
With SQL Server’s quoted_identifier option set to Off, you may receive the following error:

Run-time error ‘-2147217900 (80040e14)’:
Line 1: Syntax error near ‘tablename’ This error occurs when you are using client-side cursors with the Microsoft OLE DB Provider for SQL Server (SQLOLEDB). The error occurs on an ActiveX Data Objects (ADO) recordset’s Update method and may occur on an AddNew method.
Resolution
With ADO client-side cursors, when you invoke an ADO recordset’s AddNew or Update method, the OLE DB Provider prepares a SQL statement to send to SQL Server.
The Microsoft OLE DB Provider for SQL Server automatically quotes identifiers on an ADO recordset’s Update method and may quote identifiers on an AddNew method. Identifiers include table names and field names.
For example, updating the Titles table in the Pubs database with the following code:

MyADORecordet.Update The preceding would be prepared similar to the following:

UPDATE “titles” SET “title”=’Hello World’ WHERE “title_id”=’3′ Note that the table name is in quotes, “titles”, and that each field name is in quotes, “title”, “title_id”, and so on.
If SQL Server’s Quoted_Identifier option is set to Off, SQL Server will not recognize table names and field names enclosed in quotes.
The error “Syntax error near ‘tablename’” occurs.

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.