PRB: Listbox DTC Does Not Show Changes When Bound Recordset Changes

ID: Q229701


The information in this article applies to:
  • Microsoft Visual InterDev, version 6.0
  • Active Server Pages


SYMPTOMS

A Listbox Design-Time Control (DTC) does not reflect the changes in a Recordset DTC when the Recordset DTC changes; that is, if the result set of a Recordset DTC changes, the Listbox DTC does not show this changed result set.


RESOLUTION

To overcome this problem, you need to clear the Listbox DTC of its entries so the next change in the Recordset DTC reflects on the Listbox DTC.


STATUS

This behavior is by design.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new project in Visual InterDev 6.0.


  2. Add an Active Server Page (ASP) page (Asp1.asp) to the project.


  3. Create a Data Connection (Connection1) to the NorthWind Database, Nwind.mdb.


  4. Add a Recordset DTC (Recordset1) to the page.


  5. Set the properties of the Recordset to use Connection1, and use the Employees table.


  6. Add a Listbox DTC (Listbox1) to the page.


  7. Right-click Listbox1 and select Properties.


  8. On the General tab, set the Recordset property to Recordset1 and the Field property to the EmployeeID field.


  9. Click the Lookup tab.


  10. Select the Recordset option.


  11. Set the Rowsource to Recordset1.


  12. Set the ListField and the Bound Column each to the EmployeeID field.


  13. Click OK.


  14. Add a Button DTC (Button1) to Asp1.asp


  15. When the button is clicked the recordset is changed by using the recordset.setSQLText method. Add the following code to Asp1.asp to run for the onclick event of Button1.
    
    <%
    Sub Button1_onclick()
        strSQL = "SELECT * FROM employees WHERE EmployeeID > 4"
        If Recordset1.isOpen() Then Recordset1.close 
        Recordset1.setSQLText strSQL
        Recordset1.open
    End Sub
    %> 


  16. Save the Asp1.asp file.


  17. Right-click Asp1.asp and select View in Browser.


  18. Click Button1.


  19. This re-queries Recordset1 so it returns only records where the value of the EmployeeID field is greater than 4, but Listbox1 does not reflect the changes.


Use the following code to work around this behavior:

<%
Sub Button1_onclick()
    strSQL = "SELECT * FROM employees WHERE EmployeeID > 4"
    If Recordset1.isOpen() Then Recordset1.close 
    Listbox1.clear
    Recordset1.setSQLText strSQL
    Recordset1.open
End Sub
%> 
Using the Listbox1.clear method resets the contents of Listbox1 and forces it to update the contents when you open Recordset1.


REFERENCES

For more information on Visual InterDev and Design-Time Controls, please refer to http://msdn.microsoft.com/vinterdev.

Additional query words: kbvisID600 kbASPGrp

Keywords : kbCtrl kbVisID600 kbGrpASP kbDSupport
Version : WINDOWS:6.0; winnt:
Platform : WINDOWS winnt
Issue type : kbprb


Last Reviewed: September 23, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.