Microsoft KB Archive/248139

= BUG: MSHFlexGrid Control Empty with DataEnvironment Parameter Query =

Article ID: 248139

Article Last Modified on 1/11/2001

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q248139



SYMPTOMS
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.



RESOLUTION
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 Set MSHFlexGrid1.DataSource = DataEnvironment1.rsCommand1 where is the parameter supplied to the query.



STATUS
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.</li> From the Project menu, choose Components, and then select the Microsoft Hierarchial FlexGrid Control 6.0 (OLEDB).</li> From the Project menu, choose Add DataEnvironment.</li> Right-click Connection1, and then choose Properties.</li> On the Provider tab, specify either the Microsoft Jet 3.51 OLE DB Provider or the Microsoft OLE DB Provider for ODBC Drivers.</li> 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.</li> Click the Test Connection button. If the connection is successful, choose OK.</li> Right-click Connection1 and choose Add Command.</li> Right-click Command1 and choose Properties.</li> From the General tab, select the SQL Statement option.</li>  Enter the following SQL statement in the text box: SELECT EmployeeID, FirstName, LastName FROM Employees WHERE EmployeeID = ? </li> From the Parameters tab, make sure the Host Data Type reads as follows and choose OK:

Long (VT_I4)

</li> On Form1 of the project, add an OLEDB MSHFlexGrid control.</li> Manually set the DataSource property to DataEnvironment1.</li> Manually set the DataMember property to Command1.</li>  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" </li> <li>Run the project. The grid will be empty.</li> <li>Stop the project.</li> <li>Select the grid on Form1 and delete Command1 from the DataMember property.</li> <li>Run the project. The grid now contains one record as expected.</li></ol>

Additional query words: blank no records

Keywords: kbbug kbdataenv kbdesigner kbpending KB248139

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.