You are on page 1of 4

INFO: VB 6.

0 Readme Part 2: Data Access/Databinding Issues


The information in this article applies to:
Microsoft Visual Basic Learning Edition for Windows 6.0
Microsoft Visual Basic Professional Edition for Windows 6.0
Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q170163
SUMMARY
The information below includes the documentation and workarounds for Visual Basi
c 6.0. This information can also be found in the README.htm file that ships with
Visual Basic 6.0 on the Visual Basic 6.0 CD-ROM. Please see the REFERENCES sect
ion of this article for a list of the Microsoft Knowledge Base articles relating
to the Visual Basic 6.0 readme.
Following is a list of all parts of the readme file:
Part 1. Important Issues - Please Read First!
Part 2. Data Access Issues and DataBinding Tips
Part 3. Control Issues
Part 4. Language Issues
Part 5. Samples Issues
Part 6. Wizard Issues
Part 7. Error Message Issues
Part 8. WebClass Designer Issues
Part 9. DHTML Page Designer Issues
Part 10. Extensibility issues
Part 11. Miscellaneous Issues
Part 12. Microsoft Transaction Server (MTS) Issues
Part 13. Dictionary Object
Part 14. Visual Component Manager
Part 15. Application Performance Manager
MORE INFORMATION
Error in Data Environment Designer Code Example
In the topic, "Programmatically Accessing Objects in Your Data Environment Desig
ner," the example under "Executing a Command Object with Multiple Parameters" er
roneously uses the Open method:
MyDE.Commands("InsertCustomer").Parameters("ID").value = "34"
MyDE.Commands("InsertCustomer").Parameters("Name").value = "Fred"
MyDE.Commands("InsertCustomer").Open
There is no Open method for the Commands object. You must use the Execute method
instead.
Incompatibilities with Data-bound Controls
Due to changes in Visual Basic 6.0, not all data-bound controls are compatible w
ith all data sources. This incompatibility is due to a difference in the interna
l binding mechanisms of ADO versus DAO/RDO. Controls that were created specifica
lly to work with DAO/RDO can't be bound to an ADO Data control; controls created
for use with ADO can't be bound to the standard Data control or the Remote Data
Control.
This incompatibility primarily applies to complex-bound controls such as grids o
r lists that bind to multiple fields in a data source; simple-bound controls suc
h as text boxes or labels that bind to a single field will work with either type
of data source. Some examples are as follows:
The Microsoft Data Bound Grid control (Dbgrid32.ocx) can be bound to the DAO or
RDO Data controls; it can't be bound to the ADO Data control.
The Microsoft DataGrid control (Msdatgrd.ocx) can be bound to the ADO Data contr
ol; it can't be bound to the DAO or RDO Data controls.
The Microsoft Masked Edit Control (Msmask32.ocx) can be bound to any of the Data
controls.
The intrinsic controls (TextBox, PictureBox, Label, and so on) can be bound to a
ny of the Data controls.
Third-party controls and Visual Basic-authored User controls should be tested on
a case-by-case basis.
When attempting to bind a control to a data source at design-time, you may encou
nter a "No compatible data source" error message. In this case, you will need to
substitute another control that is compatible with your data source.
Binding to Properties of Objects May Yield Unexpected Results
While it is possible to bind any object to any other object, the results may not
always be what you expect. Some properties are read-only bindable and will not
update their bound source.
For example, if you were to bind the Caption property of a Frame control to a fi
eld named Foo in an ADO Recordset object, the Caption would change to reflect th
e value of Foo as you scrolled through the Recordset. If, however, you changed t
he Caption property programmatically (Frame1.Caption = "Bar"), the value of Foo
would not be updated. Because the Caption property of the Frame is read-only bin
dable, it doesn't provide notification that its data has changed.
This isn't a problem for Visual Basic-authored objects, since you can call the P
ropertyChanged method in your object's code. For other objects, you can determin
e if a property is update bindable by checking the DataBindings collection. If a
property is enumerated in the DataBindings collection, it is update bindable an
d the data source will receive updates to data; if it isn't enumerated, the prop
erty is read-only bindable.
Complex Binding to an ADO Recordset Requires CursorType
When binding an ADO Recordset object to a complex-bound control (such as a Grid
control), it is necessary to explicitly set the CursorType property to either ad
OpenStatic or adOpenKeyset. If you don't set this property, no data will be disp
layed. The following code shows the use of the CursorType property:
Private Sub DataClass_Initialize()
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
rs.CursorType = adOpenStatic
cn.Open "northwind"
rs.Open "customers", cn
End Sub
Binding to a simple-bound control (such as a TextBox) doesn't require a specific
CursorType.
Creating Visual Basic Data Sources: Type the Fields as adVarChar
for SQL Server and Access Databases Instead of adBSTR
When appending fields to an ADO Recordset object for use with a SQL Server or Ac
cess database, type the fields as adVarChar instead of adBSTR (as shown in some
sample code). When reading data out of either SQL Server or Access databases, AD
O will use the adVarChar type.
Incorrect References for Creating OLE DB Providers
The documentation erroneously states that it is possible to set a class module's
DataSourceBehavior property to 2 - vbOLEDBProvider to create an OLE DB data pro
vider. The correct values for DataSourceBehavior are 0 - vbNone and 1 - vbDataSo
urce.
The documentation also erroneously refers to a non-existent event in class modul
es called OnDataConnection.
Finally, in the topic "Creating the MyDataSource Class," the step-by-step exampl
e incorrectly states that you should set DataSourceBehavior to 2 - vbOLEDBProvid
er. Instead, you should set DataSourceBehavior to 1 - vbDataSource.
To create OLE DB data providers using Visual Basic, use the Provider Writer Tool
kit included with the OLE DB SDK. For more information, see the OLE DB Simple Pr
ovider Toolkit in the Platform SDK Documentation on MSDN.
Finding Help For ADO Objects
When using the ADO objects, (for example, Recordset, Connection, Command, Parame
ter, ADOR, RDS, and RDS Server object), you cannot get context- sensitive help o
n the object or its properties, events, or methods. That is, if you have a refer
ence to the object and you use one of its features, selecting the code and press
ing F1 does not result in a help topic. Instead, you will get either a wrong top
ic or the "Keyword Not Found" topic.
However, you can get help on any of the object's properties, events, or methods
by using the online documentation Index:
If the MSDN documentation viewer is not open, on the Help menu, click Contents.
Click the Index tab.
Type the name of the property, event, or method including the word "collection",
"property", "event", or "method" as appropriate.
From the list of available topics, select the topic that includes "ADO" in its t
itle.
NOTE: You can also find additional help on other ADO topics, such as the ADO obj
ect model, by looking in the MSDN Library Table of Contents: open Platform SDK a
nd under Database and Messaging Services, go to Microsoft Data Access SDK.
SQL Server OLE DB Provider Requires New instcat.sql
Before using the SQL Server OLE DB data provider, you must run the version of in
stcat.sql distributed with Microsoft Visual Basic 6.0 on SQL Server (version 6.5
and later). Instcat.sql is distributed with Visual Basic 6.0 and can be found i
n the \winnt\system32 directory upon installation.
If Instcat.sql is not run on your SQL Server, the provider is unable to retrieve
metadata from the SQL Server, and thus will not be able to connect to that serv
er.
Setup for Data Access Applications May Fail on Windows 95/98
When redistributing a Visual Basic 6.0 application that includes data access com
ponents, setup will fail if DCOM for Windows 95 and Windows 98 isn't present on
Windows 9x client machines.
The file Mdac_typ.exe is added to your setup package by the Package and Deployme
nt Wizard if your project includes references to ADO, OLEDB, or ODBC (you can ch
eck for this on the Included Files page of the wizard). This file installs MDAC
2.0 files on the client computer. MDAC 2.0 requires DCOM for Windows 95 and Wind
ows 98 in order to function properly, however it does not perform a check for th
is during setup. The setup will fail if DCOM for Windows 95 and Windows 98 isn't
present on the client machine. Some of the older data access components will be
overwritten prior to the failure, possibly causing older data access applicatio
ns on the client to fail.
When distributing data access applications for Windows 9x, you need to make sure
that DCOM for Windows 95 and Windows 98 is installed on the client. DCOM98.EXE
is a self-extracting executable file that installs the updated DCOM components f
or Windows 95 or Windows 98. It can be found in the DCOM98 directory of the Visu
al Basic 6.0 CD. This file may be freely distributed with your Visual Basic appl
ication.