BUG: OnDataSetChanged and OnDataSetComplete Events Do Not Fire Until Recordset Is Accessed (234469)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 5
  • Microsoft Internet Explorer (Programming) 5.01

This article was previously published under Q234469

SYMPTOMS

When you use the RDS Data Control to access data on a remote server, the OnDataSetChanged and OnDataSetComplete events may not fire until a method or property of the recordset is accessed. This behavior only occurs the first time the recordset is loaded into the control, and only if the event is named in the script using the ControlName_EventName syntax.

RESOLUTION

To resolve this problem, use inline event declarations or script tags specifying the object and event. To use inline event declarations, include the event name as an attribute of the object tag, and then set it equal to the name of the function you want to use for the event, for example:
<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
    ID=ADCControl 
    HEIGHT=10 
    WIDTH=10 
    OnDataSetChanged="MyDC_DataSetChanged">
</OBJECT>
				
Declare a sub in the script named MyDC_DataSetChanged and insert the code for the event.

Optionally, you can declare the event function in the script tags and specify the object and event name, as follows:
<SCRIPT FOR="MyDC" EVENT="OnDataSetChanged" LANGUAGE="JavaScript">
     // code for event here
</SCRIPT>
				

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

Insert the following code into a new HTML page:
<HTML>
<BODY LANGUAGE="VBScript" ONLOAD="Init">
<TABLE BORDER WIDTH=600>
<TR><TD>QUERY:</TD><TD><INPUT NAME=QUERY SIZE=83<TD></TR>
<TR><TD>CONNECT:</TD><TD><INPUT NAME=CONNECT SIZE=83></TD></TR>
<TR><TD>SERVER:</TD><TD><INPUT NAME=SERVER SIZE=83></TD></TR>
</TABLE>
<CENTER>
<INPUT TYPE=BUTTON NAME="Refresh" VALUE="Refresh" >
<INPUT TYPE=BUTTON NAME="RecordCount" VALUE="RecordCount" >
<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
    ID=ADCControl HEIGHT=10 WIDTH=10>
</OBJECT>
<BR>

<SCRIPT LANGUAGE="VBScript">
	Sub ADCControl_OnDataSetChanged
		MsgBox "OnDataSetChanged Event"
	End Sub

	Sub ADCControl_OnDataSetComplete
		MsgBox "OnReadyState Event"
	End Sub

	Sub RecordCount_OnClick
		MsgBox "Count of records is " & ADCControl.Recordset.RecordCount
	End Sub

	Sub Refresh_OnClick
	  ADCControl.SQL     = Query.value
	  ADCControl.Connect = Connect.value
	  ADCControl.Server  = Server.value
          ADCControl.ExecuteOption = 1 'synchronous execution

	  ADCControl.Refresh
	End Sub

	Sub Init
	   Query.value   = "SELECT * FROM Authors"
	   Connect.value = "dsn=pubs;uid=;pwd=;"
	   Server.value  = "http://servername"
	End Sub
</SCRIPT>
</BODY>
</HTML>
				

Save the page to a Web site, and load the page in Internet Explorer 5.0.

When you load the page into Internet Explorer 5.0, modify the connection string and server values to be valid, and then click Refresh. This loads data into the RDS Data Control. The OnDataSetChanged and OnDataSetComplete events should fire, but do not. Click the RecordCount button, and when you access the RecordCount property of the Data Control, the OnDataSetChanged and OnDataSetComplete events fire. Click Refresh again. The events fire immediately.

Modification Type:MajorLast Reviewed:5/8/2003
Keywords:kbbug kbpending KB234469