Create an ASP. NET data storage layer (2)

Source: Internet
Author: User

Use Visual Studio. NET to define database tables
The simplest way to define a database table in Visual Studio. NET is to create a database graph. In this way, you can define all the details in an Editor similar to "WYSIWYG. You only need to expand the corresponding tree in Server Explorer (Server resource manager), right-click the Database Diagrams (Database Diagram) item, and select New Database digoal from the context menu... (creating a database graph ...), to start a new blank graph. When you start a graph for the first time, the system requires you to select a table from the database. You can ignore this dialog box because you have not created any tables. Now, you can start to define your table.
The user solution document in the generated ASP. NET application planning and design contains the information required to define the table. It is usually the best way to learn how to add new records to the system. Sometimes you need to view other schemes such as record updates or even reports to ensure that no other fields are missing. In this example, the "add record" solution is a good reference solution.
For example, the following is a solution for adding a problem:
Add new question
Add a new question record to the system, including the title, date/time, topic ID indicating the category of the question, and question body. You may also need to provide the name and email address of the problem initiator. After a new question is added, a unique integer question ID is returned to the called function.
Important terms are in bold. When reading the solution description, these terms or table names (for example, "problem records" are a good example) often indicate what data needs to be stored. With the above information, you can add a new table in the database graph and define the required columns. The following example details how to add tables to a database graph.
Right-click the graph "surface" and select New Table... (New Table...) from the context menu ...). Enter Questions (problem) as the table name, and click OK to add it to the graph.
In the Questions (problem) Table dialog box, type the field information provided in the preceding solution. For example, Column Name = ID, Data Type = int, Length = 4, and deselect the Allow Nulls check box. Repeat the preceding operations on the remaining parts of the table (see figure 3 ).

Related Article

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.