A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service
【Key words】 ASP. net ado. NET News management database
With the popularization of the Internet, more and more enterprises have established their own WWW websites. Through the websites, enterprises can display products, publish the latest news, communicate with users, and establish contacts with partners, and e-commerce. The news management system is an important part of an enterprise website. It plays a double role. On the one hand, it can be used to dynamically publish new products or new development projects, on the other hand, you can promptly announce your business performance, technology and R & D progress, special recommendations or preferential engineering projects, products and services to customers, so as to attract customers and expand the customer base.
There are two traditional website news management methods: Static HTML pages. When updating information, you need to recreate the page and then upload the page and modify the corresponding link, this method is not applicable because of its low efficiency. Second, the combination of dynamic web pages and databases based on ASP and scripting languages to process news through applications. This is a popular practice currently. However, due to the limitations of ASP, the system has some insurmountable defects, and the systematic performance of ASP. NET technology has been greatly improved, which is mainly manifested in the following aspects:
1. because each time an ASP page is opened, it must be compiled and explained. Therefore, the speed of the page is not improved when it is opened repeatedly, whereas ASP. NET page does not need to be re-compiled once, until the page is modified or the Web application restarts. This greatly improves the speed of multiple accesses.
2. because ASP does not provide any component that outputs data as the content, you can only read records one by one using ADO RecordSet objects when using ASP to write database pages. ASP. NET through ADO. NET and other database components can directly contact the database.
3. ASP. NET supports real-time application updates. The administrator can update the application file without shutting down the network server or even stopping the application. Application Files are never locked, so they can be overwritten even when the program is running. After the file is updated, the system gently converts it to the new version.
4. ASP. NET adopts the "code-behind" method to write code, making the code easier to write and clearer in structure, reducing the complexity and cost of system development and maintenance.
1. System Development Principles
1.1 System Structure Model Based on ASP. NET Technology
The ASP. NET structure is a three-tier system: UI Layer, business logic layer, and data layer, as shown in 1.
Figure 1 system structure model of ASP. NET
The UI Layer interacts with users, receives user input, and presents data sent from the server to the customer.
The business logic layer is responsible for receiving requests from the browser and transmitting the requests to the data layer, and sending the request processing results to the browser. It consists of Web forms, XML Web Services, and component services. The Web form is ASP. the core of the NET application is to present data and information to the customer, and to respond to and process the information and data generated by the interaction between the customer and the displayed Web form.
The data layer uses ADO. NET to manipulate data to provide data services for the transaction logic layer, such as storing data operation results and returning data retrieval results.
1.2 How ADO. NET accesses the database
To connect to a database, ADO. NET provides three methods: connecting through ODBC, connecting through OLEDB, and directly connecting to SQL Server. Due to the differences in application layers, the three methods increase the efficiency from low to high, and the independence from high to low. There are two ways to process data of connected databases: one is to isolate heterogeneous data sources through DataSet, and the other is to read data from the data source through a stream (DataReader ).
Traditional applications are designed by establishing a connection to the database and maintaining the connection during the entire running process of the program. ASP. NET adopts a disconnected data structure. When the browser requests a webpage from the Web server, the server processes the request and sends the requested webpage to the browser. Then the connection is disconnected until the browser sends the next request.
Another innovation of ADO. NET is the introduction of datasets ). A dataset is a high-speed buffer that provides data relationship graphs in the memory. Datasets do not know anything about data sources. They can be generated or filled by programs or by transferring data from a data warehouse. No matter where the data is obtained, the dataset is operated by using the same program template, and it uses the same potential data buffer.
2. Functional Design of the System
2.1 functional structure of the system
The news management system can run on the Windows 2000 Server operating system platform. The Web Server is IIS, the database Server is Microsoft SQL Server2000, And the development tools are Microsoft Visual Studio. NET and DreamWeaver. Figure 2 shows the functional structure of the system. The workflow is as follows: a user can only view, read, and query news through permission judgment. a registered user can complete operations of a common user, you can also enter the news management module to input, modify, and delete news. Registered users can only delete and modify the news they have entered, except the system administrator.
2.2 system features
(1) simple operation and user-friendly interface: completely controlled page layout makes it easier to input news; many options include news categories and source departments. You only need to click the mouse to complete them. In addition, the prompt information displayed for tracking also allows you to know your operations at any time.
(2) instant visibility: the processing of News (including entry, modification, and deletion) will be immediately displayed on the corresponding topic of the home page to achieve the "instant release, immediate effect" function.
Figure 2 system function Diagram
(3) Comprehensive Functions: including news management of common websites, including news entry, browsing, deletion, modification, and retrieval, fully meets the requirements of the website for real-time news management.
(4) convenient transplantation: for different enterprises, you only need to make slight modifications to develop a website news management system suitable for the characteristics of the Enterprise!
3. Detailed System Design
The main functions of the system are implemented through several functional modules. The specific design process is as follows:
(1) system Logon: This module manages user permissions by dividing users into common users and registered users.
(2) News browsing: This module lists all news information on the website by page, including the title, type, source Department field, and release date. The title of each news item is made into a hyperlink, click them to jump to the page for news reading.
(3) news reading: Click the title link on other pages to go to the news reading page. At this time, the details of each news item will be taken out, including the content, title, and keywords, and placed in different areas of the page according to the relatively fixed format. All news uses the roughly same page layout, but the content corresponding to each field is different. In addition, other locations on the page, you can dynamically place other components, such as Website logo images, webpage advertisement banners, and other linked images. This allows you to easily read images and texts.
(4) News query: This module provides the news query function. You can enter the content to be searched and the information of the selected category to quickly find the news that meets the criteria and output the query results.
⑸ News management: This module lists the news information that has been published and not deleted by the logged-on user by page. You can delete or modify the news. Non-news publishers do not have the permission to process the news except the system administrator. Therefore, different users can access this page to display different contents.
⑹ News entry and modification: the registered user enters the content required for a news item, including the title, keyword, type, source department, and release date. At the same time, the user name is obtained from the login module, this information will be written to the database and saved. This module is also responsible for editing updates. In this case, it initializes the Page Control Based on the obtained Title field value.
The following describes the main events and functions on the system logon page, and describes the system development process.
// IsRegUserOk function: determines whether the user has been registered and the password is correct
Public bool IsRegUserOk ()
String name = TextBoxName. Text. Trim ();
String pwd = TextBoxPassword. Text. Trim ();
// Create/open a database connection
SqlConnection conn = new SqlConnection ();
Conn. ConnectionString = "server = (local); uid = sa; pwd =; database = jxdb ";
Conn. Open ();
// Create an SQL string
String SQL = "select * from reg where name = '" + name + "'";
SqlCommand cmd = new SqlCommand (SQL, conn );
Dr = cmd. ExecuteReader ();
// Retain User Registration Information
Bool isRegUserExist = dr. Read ();
// Close DataReader
Dr. Close ();
// Obtain the password of the user name
String sqlBoth = "select * from reg where name = '" + name + "'";
SqlBoth + = "and pwd = '" + pwd + "'";
SqlCommand prior both = new SqlCommand (sqlBoth, conn );
DrBoth = required both. ExecuteReader ();
// Retain the username and password information
Bool isBothExist = drBoth. Read ();
// Close DataReader
DrBoth. Close ();
Conn. Close ();
// Determine whether a user is registered
If (! IsRegUserExist)
Response. Write ("<script> alert ('the user is not registered yet! ')");
// Determine whether the user name and password are consistent
Else if (! IsBothExist)
Response. Write ("<script> alert ('the user name and password are inconsistent and cannot be entered! ')");
Finally, the system back-end data storage solution is provided:
Use Microsoft SQL Server 2000 to create a database and its stored procedures. Two required data tables are provided. First, the data table News contains the following fields: ID, name, title, keyword, content, type, source department, and date. The fields are described as follows:
Second, the Reg table contains the following fields: number, name, password, department, email address, and phone number. The fields are described as follows:
Start building with 50+ products and up to 12 months usage for Elastic Compute Service