PRB: Data Object Wizard Fails If Field Names Contain Spaces
ID: Q190112
|
The information in this article applies to:
-
Microsoft Visual Basic Professional and Enterprise Editions for Windows, version 6.0
SYMPTOMS
When you run the Data Object Wizard against a Data Environment Command
object, you may receive the following error message:
The field 'xxx yyy' has a space in it. You cannot select a Command where
a field has a space in its name.
CAUSE
This error occurs because the Data Object Wizard creates methods
corresponding to field names, and method names cannot contain spaces in
them.
RESOLUTION
Rename fields to eliminate spaces, or base the Command on a SELECT
statement where the field names are aliased to remove spaces.
STATUS
This behavior is by design.
MORE INFORMATIONSteps to Add a Field Name with a Space
NOTE: Not all data providers support this technique. For instance the
Microsoft Jet 3.51 OLE DB Provider does not support this technique. In this
case, you can use a tool, such as VISDATA, which is one of the Visual Basic
sample applications, or Access, to change the field names.
- Open a new Standard EXE project in Visual Basic 6.0.
- Open the Data View window (on the View menu, click Data View Window).
- Right-click Data Links in the tree-view and add a new data link with the
following properties:
- Provider Tab: Select Microsoft OLE DB Provider for ODBC Drivers.
- Connection Tab: Provide the connection to your SQL Server database
and choose "pubs" as the initial catalog name.
- Click OK on the Data Link properties dialog box.
- Expand the tree under the newly added datalink (DataLink1) to expose:
DataLinks\DataLink1\Tables\Authors
You may have to complete an ODBC login dialog box.
- Right-click "authors" and select Design.
- In the design view, rename au_lname to au lname.
- Close the designer and save the changes. You do not have to save the
script generated by the designer.
Steps to Activate the Data Object Wizard
- In your Visual Basic 6.0 project, activate the Add-In Manager (Add-Ins
menu).
- Select the VB6 Data Object Wizard. If it is not already loaded, click
the Loaded/Unloaded check box.
- Click OK on the Add-In Manager dialog box.
Steps to Add a Data Environment
- In your Visual Basic 6.0 project, click Project, then Add Data
Environment.
- In the Data Environment designer, right-click Connection1 and choose
Properties.
- Set the Data Link Properties:
- Provider Tab: Select Microsoft OLE DB Provider for ODBC Drivers.
- Connection Tab: Provide the connection to your SQL Server database
and choose "pubs" as the initial catalog name.
- Click OK on the dialog box. NOTE: You may also have to complete an ODBC
login at this point.
- Right-click Connection1 in the Data Environment designer and choose Add
Command. This creates Command1.
- Right-click Command1 in the Data Environment designer and choose
Properties.
- In the Command1 Properties dialog box, set the following:
General Tab: Database Object: Table
Object Name: authors NOTE: You may have to complete an ODBC login dialog box at this point.
- Click OK on the Command1 Properties dialog box.
- Close the Data Environment designer.
Steps to Reproduce the Bug
- In your Visual Basic 6.0 project, click Add-Ins, then VB6 Data Object
Wizard.
- In the wizard, click Next to bypass the Introduction page and the Create
Object page, accepting default values for these settings.
- On the Select Data Environment Command page, select the Command object
created in the previous sections and click Next. The error is displayed.
Additional query words:
kbvbp600 kbDatabase kbDataview kbAddIn kbdse kbDSupport kbVBp
Keywords : kbGrpVBDB
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbprb
|