The application of ASP technology in e-commerce

Source: Internet
Author: User
Tags execution html page http request implement insert connect odbc thread
E-commerce Author: Pan radium

Content Summary: This article elaborated the ASP technology the function and the characteristic and in the electronic Commerce application.

Key words: ASP, e-commerce.

ASP technology ASP (active Server pages Dynamic Web page) is a technology introduced by Microsoft to replace the CGI (Common Gateway Interface Universal Gateways Interface). Currently, many windows-based Web sites on the Internet have started to use ASP to replace CGI. Simply put, ASP is a server-side scripting environment in which users can create and run dynamic interactive Web server applications, such as interactive dynamic Web pages, including the use of HTML forms to collect and process information, upload and download, and so on. Typically, Web pages that users see through the browser are mostly static, and many sites on the Internet today still provide static home page content. The so-called "static", refers to the site's homepage content is "fixed unchanged." When the browser requests the content of the home page from the HTTP (Hypertext Transport Protocol) protocol of the Internet to the site server (WEB server), when the site server receives the request, it transmits the original designed static HTML File data to the browser. A "static" site, to update the contents of the home page, you must manually update its HTML file data. With the development of Web applications, users want to be able to see dynamically generated home pages, such as responding to user query database requirements, generating reports, and so on. An application that can be executed on the site server, not just an HTML file, when the input data for form (form) is filled out in the browser to provide HTTP requirements. The site server receives the application that requires execution, analyzes the input data for the form, and sends the results of the execution to the browser in HTML format. The traditional way to generate dynamic home pages based on user requests is CGI, ISAPI, and so on. CGI activates the response process based on a browser-side HTTP request, with each request corresponding to a process. When there are many requests at the same time, the program crowding out the system resources, resulting in inefficient; the ISAPI has improved on this shortcoming, using DLL (dynamic link library) technology to replace the process with the thread, improve performance and speed, but consider the thread synchronization problem, and the development steps cumbersome. The two technologies and another commonly used technology for developing dynamic Web pages have another problem: development difficulties, program development and HTML writing are two completely different processes that require specialized programmer development. And more simple development technology such as JavaScript and IDC (Internet Database Connector) and other functions are limited, not enough to use. The ActiveX technology used by ASP is based on an open design environment where users can define and make components themselvesJoin in, so that their dynamic Web page has almost unlimited capacity to expand, this is the traditional CGI and other programs far from the place. Unlike Java applets, ActiveX control, VBScript, JavaScript, and other technologies that are common in implementing dynamic home pages on the client side, ASP commands and script statements are interpreted by the server. The execution results generate dynamically generated Web pages and are sent to the browser, while client-side technology script commands are interpreted by the browser. Because the ASP is interpreted on the server side, developers do not have to consider whether the browser supports ASP, and because it executes on the server side, developers do not have to worry about others downloading programs to steal programming logic. ASP is implemented by the ASP file suffix named. asp, an. asp file is equivalent to an executable file, so it must be placed in a directory with executable permissions on the Web server. When the user enters the address of the. asp file from the browser, the browser sends the URL request to the Web server, and if the Web server has ASP on it, the ASP is invoked. The ASP reads the corresponding. asp file, interprets and executes commands, dynamically generates an HTML page to return the Web server, and then the Web server sends the results to the browser. ASP files are produced and HTML-like, and are integrated with HTML development and can be done in the same process, using ASP to embed scripts that can be executed into HTML files (change the suffix name of HTML file to. asp), which makes the authoring of HTML files merged with the development of scripts. With ASP's built-in objects, server components (server Component), you can accomplish very complex tasks, and users can also develop or leverage server components developed by others to accomplish specialized tasks. ASP comparison gateway and server extension mode have the following advantages:

(1) completely merged with the HTML file;

(2) Easy to create, do not need other compile, link program;

(3) Object-oriented and extensible through an ActiveX server object.

Ii. e-commerce data access methods

E-commerce refers to the activities of business exchange through electronic means and the coordination of material and personnel processes on the basis of the network. In the e-commerce system, the Web provides an effective means of communication with customers, using Web technology, Web server and database system to connect, complete the processing and query of data, users can operate a simple and easy to learn the browser to query processing of the various data needed. There are generally two ways to implement a Web server's connection to a database:
One is the use of middleware technology to establish connectivity and communication between the two, such as CGI (Common Gateway Interface) and API (application programming Interface). The Web server implements the interaction with the Web browser by invoking the CGI program, which means that the CGI program accepts the browser's message to the Web server, processes it, sends the results back to the Web server, and transmits the information to the browser through the Web server. But the CGI program has a great limitation in response speed and resource utilization, client each request a CGI program, the server will open a process, when the number of requests is likely to cause bottlenecks, developers often use API programming to expand the server function, API programs account for less system resources, operating efficiency, But its programming is more complicated than the CGI program;
The other is a Java applet in the browser that accesses a database on a Web server through a browser, leveraging JDBC (Java Database Connectivity) technology, which implements the API provided by JDBC to web Server's access. Due to the limitations of Java applets, most of the applications are based on middleware technology at present. ASP is also a model of middleware, but it has great advantages in comparing gateway and server expansion mode on Windows platform. The biggest feature of a gateway is its platform independence, but gateway programs are often harder to write and change. The gateway program is usually a stand-alone program that does not mix with HTML files, it needs to write stand-alone applications in languages such as C, C + +, VB, and Perl, and the ASP application changes that. Not only can you use ASP to read databases from Access and SQL Server, but you can also read other databases that are compatible with open database Connect open databases. Access to the database in ASP is achieved through ADO (ActiveX database object activity data object) and transaction processing statements. ADO is a way to operate a database supported by Microsoft and is an easy-to-use and extensible technique for adding database access to a Web page. ADO objects are used in the same way as DAO (data Access Objects), RDO (Remote Data Objects). In ASP, ADO can be regarded as a server component, simpler to say, is a series of objects, the application of these powerful objects, can easily complete the complex operation of the database.

The application of ASP in e-commerce

In E-commerce, for users, the purpose of online information inquiry is to find the products or services they need, and for goods or service providers, the purpose is to sell their products or services to users. Therefore, allowing users to query the server's back-end database through a browser is a required service for many Web service providers, and ASPs implement this functionality through the built-in ADODB components. You can use ADO to write compact and concise scripts to connect to an ODBC-compliant database and OLE DB-compliant data sources. Specific steps can be summed up in the following steps:

① CREATE DATABASE Source name (DSN) ADODB work through ODBC, so set the DSN (data source name) in ODBC. Open the Windows Control Panel, double-click the ODBC icon, select the Properties page for the file DSN, press < Add, select the database driver, click Next, and follow the on-screen instructions to type the name of the data source file, click Next, and then click Finish creates the data source.

② Create a database link link to maintain some dynamic information about the data being accessed, as well as the linker information. Using the ADODB member function open and the previously set DSN to connect to the database, the syntax is as follows: Setconnect=server.createobject ("ADODB.") Connection ")" Creates a linked object connect. Connect.open ("Dsn=dsnname;uid=userid;pwd=password") ' opens the link. DSNname is the data source name; UserID is the user name; password is the user's password.

③ Create a data object the data object in ADO usually holds the query results. The RecordSet is the most complex object in ADO, which has many properties and methods, and can achieve many good effects. The method is created as follows: Set recordset =connect.execute (SQTSTR) ' Creates and opens the object RecordSet, Sqtstr is a string that represents a standard SQL statement. For example, after sqlstr= the statement "Select*from B1" Set RecordSet =connect.execute (SQLSTR), all records in the B1 are saved in the object RecordSet.

The ④ operations database can use execute to easily insert, modify, delete, and so on. such as insert operation: sqlstr= "INSERT into b1values (1,2)" Connect.execute (SQLSTR)

⑤ Close Data Objects and links after you use the ADO object, be sure to close the data objects and links. In ASP, the shutdown is implemented by calling method close. Closes the created data object: The record Set. Closed set record set=nothing closes the created link object: Connect. Close Set connect=nothing Complete program fragment: <% setconnect=server.createobject ("ADODB. Connection ") ' produces the component instance Connect.open (" Dsn=dsnname; Uid=userid; Pwd=password ") ' Connect database sql=select*fromtablename setrs=connect.execute (SQL) ' Execute query%> <%dowhile not RS. Eof%> ' Display results <%=rs (fieldname)%> <% rs.movenext Loop%> The above is the entire process of accessing the database with ASP, because of the application of object-oriented thinking, all operations are relatively simple, user Need to pay attention to is only the understanding of the data structure, the object and the object and so on, as long as there is a clear understanding of these, coupled with the powerful ASP, the use of databases on the network, to achieve the exchange of information between users and pages, it is no longer difficult.

Conclusion: With the development of web technology, e-commerce system based on intranet undoubtedly has more application foreground than traditional commerce, and how to raise the department high this data interview in Electronic business organization



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.