Ultradev Example Tutorial: 2.1 Create a simple Access database

Source: Internet
Author: User
Tags add date current time interface key table name access database access
access| Tutorials | data | database Chapter II: Setting Up a database

in the first section, create a simple Access database

In this section we will learn about database creation, and friends who have used access to create databases can skip it.

Open Microsoft Access, select File-〉 to create a new database, and then choose a location to save your database file, which we have named save by its default Db1.mdb.



After you save the database, we see the following interface, double-click to create a table using the designer, and start creating a datasheet. Our application here you just follow the steps step-by-step, even if you have never contacted the database is no problem, if you want to do deep application, related to the structure of the relationship, it is best to find a database of books to see.



Next we design a user information table for users to register. Double-click to create a table using the designer to open the design interface. In the Field Name column to fill in the user information you want to record (best field name not in Chinese to name, so later programming will not have too much trouble, but also should be careful not to use the database of their own reserved words---such as temp, such as the database program will have conflicts, as far as possible with table name + slide Line + Name, such as Tbl_userinfo_name, where we first use a simple naming process. We have created 6 fields, namely username (save user ID), userpass (user registration password), Usermail (user's e-mail address), Reg_date (user registration time), homepage (User's personal homepage address), Phone (user's contact number). The data type uses its default text type with a field size of 50, and we then handle individual fields.
Generally speaking, user name, password, e-mail address, contact phone number will not exceed 50 characters (of course, if someone malicious input too long string words will be an error, so we have to do some restrictions on the next page production), and the personal homepage address, it may be more than---such as http:// Www.netease.com/~cosix/html/..., so we adjust its field size to 200.



The time type of the registration date is changed to date/time, *_ ' of course. Then we can call access's own function to add a default value for him, =now (), which means that when the data is added, the database system automatically takes the server's current time as the value of the Reg_date field, so that we can omit the step of making the registration date in the Web page.



After the modification, click on the Save Chart on the toolbar to save our newly created table, which will jump out of a warning dialog box and tell you that the table has not yet defined a primary key. Without a primary key, it is not possible to determine the unique status of the record in the table so that it is wrong to delete or edit the record, so we create a primary key. The value of the primary key is not duplicated. Click Yes to create the primary key.


As shown in the figure, a primary key named ID (with a key icon next to it) is created, and the data type is AutoNumber.



In the Click to save, this time you enter the name of the saved table, we named UserInfo.



A table is created! Is it simple?




Because we have not yet learned how to make the content of the added records, so here we add some content manually to facilitate the test we will be doing later. As pictured.



Well, a complete database is set up, what to do next, um, and listen to let's.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.