Ultradev Example Tutorial: 3.4 Adding Records to the Database
Author:Eve Cole
Update Time:2009-05-30 18:34:47
Chapter 3: Applying Database to Create Dynamic Web Pages
Section 4: Add records to the database
When there was no record in the database earlier, for the convenience of testing, we directly operated the database and added several pieces of data to it. The following content teaches you how to create a page for submitting data, so that we can add data to the database through the browser. This is the more popular browser-server mode. *_"
Okay, let's get started!
The first step: open Ultradev---haha, nonsense.
Open the menu Insert -> LiveObjects -> Record Insertion Form, as shown in the figure below:
After selecting, the following dialog box for inserting data form properties appears.
Connection is the database connection we have defined in the site. After selecting it, the table in the database you are connected to will appear in the Insert Into Table column, from which you can select the table into which you want to insert data. Our database has only one userinfo table, select it. Then in the Form Fields below, the fields we designed in the table design and their related properties will appear. Column represents the field name in the database table, and Display As represents what type of form field is used, such as text form field (Text Field) to submit our records, Submit As indicates what data type to submit as. For example, if the data type is an integer field, we cannot submit it with a text data type. Generally, Ultradev will automatically select this column for us. Label will help prompt you to fill in the content of this form field. After Inserting, Go To column means to jump to that page after you submit the data. For example, after successful registration, it will jump to a page to tell you that you have successfully registered and you are welcome to use it. That's it. Son's. If you fill in nothing, it means you will return to this page after submitting the data.
Next, select the fields we want to add data to. Here, the ID is automatically numbered and automatically generated by the database, so we do not need to operate it. Select this row and click the button with "-" to delete it. We gave the Reg_date field a default value =Now() when designing the database. It will also be automatically generated by the database without our intervention, so it is also deleted. Then we change the Label to Chinese, so that a data adding form is ready, as shown in the picture below:
After clicking OK, the page shown in the figure below is generated. Wow! Does it look familiar? Haha, a simple user registration page is completed, So Easy! If you are interested, you can take a look at the code Ultradev generated for us. It is very long!
Oh, don’t forget that there is one more place to set, which is the form field attribute of the user password part. You need to set its type to Password, as shown below. In this way, when entering the password, it will not be displayed in plain text, but * will be used instead.
Save the page, and then let's try our results right away. Open the browser, enter the address, and fill in some data, as shown below:
Click Insert Record to submit the data, and then jump to the page that displays the data. Haha, you see, the data we just entered is lying there obediently. I believe you have experienced the power of Ultradev again. Just move the mouse a few times, and a fully functional page will appear. If you write it by hand, you still don’t know how long it will take to write, and you have to keep testing.
In fact, this registration function is still imperfect. For example, what should I do if repeated data entry is used? What should I do if a user fails to fill in some content? These issues will be discussed later in the Ultradev Advanced User Guide, so please be patient.
Okay, next time we will talk about how to edit records in the database. Well, what if I accidentally enter the wrong data? What if I don’t change it? As for how to do this, we will explain it next time.