Microsoft KB Archive/263621

= PRB: Records Are Not Added When addRecord and updateRecord Methods Are Used in Same Event =

Article ID: 263621

Article Last Modified on 4/21/2001

-

APPLIES TO


 * Microsoft Visual InterDev 6.0 Standard Edition

-



This article was previously published under Q263621



SYMPTOMS
If the addRecord and updateRecord methods of a Recordset Design-Time Control (DTC) are used in the same event (for example, button_onclick), you may find that the new record is not added or that unexpected results occur.



CAUSE
Both of these methods require a round-trip from the client to the server. However, only one trip to the server can occur from an event. The problem behavior occurs because there is an attempt to make two trips to the server from the same event.



RESOLUTION
There are two ways to work around this problem:
 * Use two different events, one for each method. For example, use two buttons (btnAdd and btnSave) and place the addRecord method in the btnAdd_onclick event and the updateRecord method in the btnSave_onclick event.
 * If you need to add a record from within the same event, use the addImmediate method of Recordset DTC in place of the addRecord method.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Add an Active Server Pages (ASP) page to the project. Add a Recordset DTC. Enable Scripting Object Model when you are prompted to do so. Add a Button DTC, and rename it btnOneEventAdd . Open the Script Outline window (from the View menu, select Other windows, and then select Script Outline). Locate and expand the btnOneEventAdd object (expand Server Objects & Events), and double-click onclick event.</li>  Place the following code in the generated onclick event: Sub btnOneEventAdd_onclick Recordset1.addRecord Recordset1.fields.setValue &quot;value&quot;, &quot;123&quot; Recordset1.updateRecord End Sub </li> View the page in the browser and check the results in the database.</li></ol>

<div class="references_section">