UD40 Ultradev Tutorials
Home

Tutorials

Search

Links

Credits

Feedback
Home | Search | Back
Tutorial 8 - Update records in different tables
Do you know that you can easily update records in different tables in a database from a single form using UltraDev?

There is not much to it actually. Imagine we have a database with two tables called One and Two. Again, these two tables each has a field called One and Two respectively. I have made a single entry in the tables as shown below:




We will start by building a form with two text fields and call them One and Two. Set the action of the form to an ASP page which will do the actual inserting. In our example we will call this page as 1.asp.



We will be updating the value alpha in table One with the value of the text field called One and the value beta in table Two with the value of the text field called Two. I hope you are not confused with the names :)

Create a new document and call it 1.asp. Go to the Data Bindings pallete and select Command (Stored Procedure). Setup the Command as shown in the screen shot below:



Repeat the procedure for Command2. The SQL is almost identical for both Commands.



Add by hand an extra line at the end of each Command to set the Command to Nothing.

Finally let's put something on the screen to tell us that the update has been completed successfully. Add the following to the HTML portion of 1.asp:

Alternatively you can place a redirect below the Commands to redirect to a page of your choice.

For practical use you can add all kinds of conditions to the WHERE clause of the SQL statement of the Commands, for example:

UPDATE Two
Set Two = 'varTwo'
WHERE ID = Session("UserID")


Note 1: For some unknown reason, UltraDev 1 tends to lose the run-time value of the Commands if we click on them to view their contents after creating them.

Note 2: The above method can also be used to insert values into different tables in a database. Just change the Command type to Insert.


No Demo | Back


Copyright © 2001, Swee Hoe Ong
All rights reserved.