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 data control’

FIX: ADO DataControl and DataEnvironment Events Only Work with ADO 2.0

Symptoms
When you attempt to use the events of an ADO Data Control or the DataEnvironment with a reference to a version of the Microsoft ActiveX Data Objects (ADO) later than version 2.0, you receive the following error message:

Compile error:
Procedure declaration does not match description of event or procedure having the same name.
Resolution
The ADO Data Control and the Data Environment were compiled using Microsoft Data Access Components version 2.0.

BUG: UserControl Containing ADO Data Control Fails to Unload

Symptoms
When a contained (inside a UserControl) control’s DataSource property is set to a contained ActiveX Data Objects (ADO) Data Control (MSADODC.OCX) at run-time, the container UserControl may fail to unload even when the form hosting the control is unloaded. As a result, the Terminate event of the UserControl does not fire as expected and if the form hosting the control is repeatedly loaded and unloaded, a memory leak may occur.
Resolution
To work around the problem, use a temporary recordset as described in the “More Information” section.

BUG: UserControl Containing ADO Data Control Fails to Unload

Symptoms
When a contained (inside a UserControl) control’s DataSource property is set to a contained ActiveX Data Objects (ADO) Data Control (MSADODC.OCX) at run-time, the container UserControl may fail to unload even when the form hosting the control is unloaded. As a result, the Terminate event of the UserControl does not fire as expected and if the form hosting the control is repeatedly loaded and unloaded, a memory leak may occur.
Resolution
To work around the problem, use a temporary recordset as described in the “More Information” section.

PRB: Executing Refresh Method of ADO Data Control Causes Syntax and Method Refresh Errors

Symptoms
When you set the RecordSource property of an ADO Data Control to a different SQL SELECT statement and then try to execute the Refresh method, the following error is returned:

Syntax error in FROM clause.which is followed by:

Run-time error ‘-2147217900(80040e14)’:
Method ‘Refresh’ of object ‘IAdodc’ failedor:

Method ‘Refresh’ of object ‘IAdodc’ failed when attempting to refresh an ADODC after setting the recordsource property to another value.The errors occur if the CommandType property of the ADO Data Control is set to adCmdTable.
Resolution
When the CommandType of the ADO Data Control is set to adCmdTable, “SELECT * From” is automatically prepended to the RecordSource value.
Setting the RecordSource to a table name results in a valid SQL statement, such as SELECT * FROM Tablename.
Setting the RecordSource to a SQL SELECT statement, such as Select * From Tablename, results in a SQL statement ofSelect * From Select * From Tablename, which is an invalid SQL statement.

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.