PRB: RDC Refresh Method Failure with Bound DBListbox
ID: Q154817
|
The information in this article applies to:
-
Microsoft Visual Basic Enterprise Edition, 32-bit only, for Windows, version 4.0
SYMPTOMS
If you change the SQL Property of a Remote Data Control with a bound
DBListbox at run time, the refresh method doesn't show the changes in the
DBListbox as it does for other controls. The Refresh method must be
called twice.
RESOLUTION
Refresh the remote data control twice. Replace the Command1_Click in the
previous sample with the code below:
Private Sub Command1_Click()
' Restrict the SQL to display only the authors whose last name
' start with an R
MSRDC1.SQL = "SELECT * FROM Authors WHERE AU_Lname LIKE'R%'"
MSRDC1.Refresh
MSRDC1.Refresh
End Sub
STATUS
Microsoft is researching this problem and will post new information here in
the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
Steps to Reproduce Problem
- Create a new ODBC data source for SQL Server called "RefreshTest" using
the "32-bit ODBC" section of the Control Panel. Set the database name to
the "Pubs" Database.
- Start a new Visual Basic Project. Form1 is created by default.
- Add the following controls to Form1 and give them the properties
indicated:
Default Name Caption Name
-------------------- ----------------- ----------
Remote Data Control Authors MSRDC1
Command1 Change SQL Command1
DBList Not Applicable DBList1
- Set the DBList Control RowSource property to MSRDC1.
- Add the following code to the General Declarations section of Form1:
Option Explicit
Private Sub Form_Load()
MSRDC1.DataSourceName = "RefreshTest"
MSRDC1.SQL = "Select * from Authors"
MSRDC1.Refresh
DBList1.ListField = "Phone"
End Sub
Private Sub Command1_Click()
' Restrict the SQL to display only the authors whose last name
' start with an R
MSRDC1.SQL = "SELECT * FROM Authors WHERE AU_Lname LIKE'R%'"
MSRDC1.Refresh
End Sub
- Press the F5 key to run the project. The DBListbox will contain many
rows of data.
- Click the Command button "Change SQL," and note that the DBListbox
doesn't change to reflect the new SQL.
REFERENCES
Building Client / Server Applications with Visual Basic Chapter 11.
Additional query words:
remote data control rdc
Keywords : kbVBp400 PrgOther VB4WIN kb32bitOnly
Version : 4.0
Platform : NT WINDOWS
Issue type : kbprb