Microsoft KB Archive/248139
Article ID: 248139
Article Last Modified on 1/11/2001
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
This article was previously published under Q248139
When using the Microsoft Hierarchial FlexGrid Control to display data from a DataEnvironment Parameterized Query, data does not display if the FlexGrid's DataMember property is set both at design-time and at run-time.
Any of the following methods are valid ways to set the Hierarchial FlexGrid's DataMember and DataSource properties:
- If you are setting the DataMember property at run-time, do not set it manually at design-time.
- Set both the DataSource and DataMember properties at design-time. If you do this, do not set either property at run-time.
Set both the DataSource and DataMember properties at design-time and run-time. However, at run-time set the Datamember equal to an empty string before setting it to your command. For example:
MSHFlexGrid1.DataMember = "" MSHFlexGrid1.DataMember = "Command1"
- Set neither the DataSource nor the DataMember properties at design-time. Instead, at run-time execute the DataEnvironment command and set the DataSource property programmatically as follows:
DataEnvironment1.Command1 <param> Set MSHFlexGrid1.DataSource = DataEnvironment1.rsCommand1
where <param> is the parameter supplied to the query.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Steps to Reproduce Behavior:
- Create a new Visual Basic Project.
- From the Project menu, choose Components, and then select the Microsoft Hierarchial FlexGrid Control 6.0 (OLEDB).
- From the Project menu, choose Add DataEnvironment.
- Right-click Connection1, and then choose Properties.
- On the Provider tab, specify either the Microsoft Jet 3.51 OLE DB Provider or the Microsoft OLE DB Provider for ODBC Drivers.
- On the Connection tab, depending on the provider you selected in the last step, either choose the Nwind.mdb database or choose a data source name (DSN) that points to the Nwind.mdb database. Use Admin as the user name. On a system that has not setup Microsoft Access security, there will be no password for the Admin user. If you have setup Microsoft Access security, enter the password for the Admin user.
- Click the Test Connection button. If the connection is successful, choose OK.
- Right-click Connection1 and choose Add Command.
- Right-click Command1 and choose Properties.
- From the General tab, select the SQL Statement option.
Enter the following SQL statement in the text box:
SELECT EmployeeID, FirstName, LastName FROM Employees WHERE EmployeeID = ?
- From the Parameters tab, make sure the Host Data Type reads as follows and choose OK:
- On Form1 of the project, add an OLEDB MSHFlexGrid control.
- Manually set the DataSource property to DataEnvironment1.
- Manually set the DataMember property to Command1.
Paste the following code into the Form_Load event:
If DataEnvironment1.rsCommand1.State = adStateOpen Then DataEnvironment1.rsCommand1.Close End If DataEnvironment1.Command1 2 MSHFlexGrid1.DataMember = "Command1"
- Run the project. The grid will be empty.
- Stop the project.
- Select the grid on Form1 and delete Command1 from the DataMember property.
- Run the project. The grid now contains one record as expected.
Additional query words: blank no records
Keywords: kbbug kbdataenv kbdesigner kbpending KB248139