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 for April, 2010

PRB: DataGrid Control Does Not Return Contents of Edited Cell

Symptoms
The Microsoft DataGrid Control 6.0 (OLEDB) does not return the contents ofan edited cell.
Using the CellText properties of the Column object returns the originalvalue of the text currently in the cell and not the text the user hasedited. This behavior differs from the Data Bound Grid Control that returnsthe value of the user-edited text.
This scenario may be problematic for a developer who would like to validatethe contents of the cell before the contents are placed in the recordset.
Resolution
The DataGrid control provides a window handle to the cell being edited.Using this handle and the GetWindowText API, the developer can get thecontents of the edited cell before the contents are saved in the recordset.

PRB: DAO Run-Time Error 3146 When Modifying SQLServer Data

Symptoms
When attempting to delete or update a record in a SQL Server cursor, the delete or update operation succeeds, but the following error returns:

Run-time error 3146 “ODBC call failed”.
Resolution
This behavior occurs when SQL Server does not return a message indicating the number of rows returned by a statement. SQL Server does not return a message indicating the number of rows affected by a statement after the following commands have been executed on SQL Server:

sp_configure “user options”, 512SET NOCOUNT ON

PRB: CompactDatabase Method Requires Locale to Convert 2.0 MDB

Symptoms
When attempting to use the Data Access Object (DAO) 3.5 CompactDatabasemethod to convert a Jet 2.0 .mdb file to a Jet 3.0 file format, theresulting .mdb file is still in a Jet 2.0 file format.
Resolution
DAO 3.5 requires you to provide explicitly the locale argument of theCompactDatabase when converting .mdb file formats.

PRB: COleControl::Serialize Not Called with VB as Container

Symptoms
Although OLE controls are used with certain control containers (such asMicrosoft Visual Basic version 4.0), the Serialize function for the control-derived class is not called. These containers allow the control to storeits persistent information either by using the property sets or by usingthe IPersistPropertyBag interface. Both these methods callCOleControl::DoPropExchange directly without calling the control’sSerialize function.
The resolution section of this article discusses a technique that you canuse in the DoPropExchange method to store CObject-derived objects.
Resolution
COleControl::Serialize is called by the framework when an OLE controlcontainer uses one of the following persistent storage interfaces forloading and saving the control: IPersistStorage, IPersistStreamInit, orIPersistMemory.
If a control container uses any other method to store the control’spersistent information, then Serialize for the control-derived class willnot be called. Microsoft Visual Basic, for example, uses eitherIPersistPropertyBag or property sets to store the persistent informationfor an OLE control; therefore, the Serialize function for a control is notcalled when Visual Basic is used as the control container.

PRB: CLSID {00000010-0000-0010-8000-00AA006D2EA4} Not Found When You Run an Application

Symptoms
When you first try to run an application that a Visual Basic 6.0 Setup package installed and that the Packaging and Deployment Wizard (PDW) created, you may receive the following error message:

Class not registered.
Looking for object with CLSID {00000010-0000-0010-8000-00AA006D2EA4}.
Resolution
This error occurs when the Visual Basic 6.0 project references the Microsoft Data Access Objects (DAO) 3.6 Object Library (DAO360.dll) and not DAO350.dll. The {00000010-0000-0010-8000-00AA006D2EA4} CLSID is associated with DAO350.dll.
When the intrinsic Data control’s Connect property is set to Access, and the application uses this Data control, the application requires that DAO350.dll is registered on the system. However, DAO350.dll is not included in the distribution package that the PDW creates because it is not referenced in the project.

PRB: Client-Side ADO Union Query Using Oracle OLE DB Provider Returns Incorrect Number of Columns

Symptoms
When you create a recordset with ADO 2.5 that contains a Union Query, client-side cursors and the Microsoft Oracle OLE DB Provider return an incorrect number of columns.
This problem does not occur if you use the OLE DB Provider for ODBC Drivers and the Microsoft ODBC for Oracle Drive.
Resolution
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.