As Microsoft launched the Web and database solutions, ASP because of Microsoft's unique operating system and other technical backing support, so has been rapid development, and is receiving more and more welcome, in the current construction of e-commerce sites have many use ASP to write programs.
Recently, many readers have consulted us on the methods of learning ASP and some problems encountered in learning, some of which are frequently encountered and faced by beginners. In order to let the reader in the process of learning ASP to deepen the understanding of ASP, and can effectively solve the problems encountered, we have specifically collected some of the more representative of the problems, listed here and give answers, hope to be in this limited space for you to learn ASP help.
1. Question: Is ASP a programming language?
A: ASP is not a programming language, but a development environment. ASP provides an environment for executing instructions on the server side, which uses special symbols () to differentiate between HTML and commands that must be translated by the server to be sent to the client. The directives it can execute include HTML languages, Microsoft VBScript, and Microsoft JScript, and so can make powerful Web applications.
2. Question: Can I use PWS to accommodate multiple Web sites on a Web server?
Answer: Only one Web site can be accommodated on the PWS. To accommodate multiple Web sites on the same computer, you need to use Windows NT Server or Windows Server/professional and IIS.
3. Question: How do I use 6 built-in ASP objects?
A: ASP provides multiple inline objects that can be directly accessed and used in directives without establishing them, and these six objects are: Request object, Response (Response) object, Work stage (Session) object, Application (application) object, The server (Server) object, the cookie object, the server object in these six objects can load other components, which can extend the functionality of the ASP.
Using the object created by Server.CreateObject, its life cycle begins when it is established and ends at the end of the Web page where it is located. If you want the object to be used across Web pages, you can use the session object to record the object that Server.CreateObject created.
4. Question: Why do I get the following error when I use Response.Redirect: "header error, the HTTP header has been written to the client browser, the title of any HTTP changes must be written before the page content"?
A: Response.Redirect can transfer the Web page to another page, using the syntax structure is this: Response.Redirect URL, where the URL can be a relative address or absolute address, but in IIS4.0 use and in IIS5.0 use is different.
The IIS4.0 transfer page must be done before any data is output to the client browser, or an error will occur. Here the so-called data include the HTML label, such as:< html>,< body>, and so on, and in the IIS5.0 has been improved, in the IIS5.0 by default, the buffer is open, such errors no longer occur.
There is a buffer property in the response object that sets whether the Web site will transfer data to the client immediately after processing the ASP, but the property must be set before any data is sent to the client.
For the sake of insurance, regardless of the ASP running platform, at the beginning of the page write <% response.buffer=true%>, set the buffer to on, so that the error will not occur.
5. Question: Does the buffered output have any effect on the transmission of the web?
A: In a larger web page, there may be some delay in the first part appearing in the browser, but loading the entire Web page is faster than not buffering.
6. Question: Can I use the Request.QueryString collection for the value of the query string when there is no form submission?
A: The request object is used to read the data in the browser, in addition to reading the contents of the form field, it can also be used to read the parameters that come with the URL, no matter how the request string is added to the link address, it is not different for requests. You can use the Request.QueryString collection to submit a form using the Get method, or to follow an additional query string with all values in the link query strings.
7, question: I wrote a lot of comments in ASP script, this will not affect the server processing ASP file speed?
A: In the process of writing a program, it is good practice to make comments. After testing by foreign technicians, the overall performance of ASP files with too many annotations will only decrease by 0.1%, which means that the performance of the server will not be degraded in practical applications.
8, question: need not at the beginning of each ASP file to use <% @LANGUAGE =vbscript;?
Wuhan 161 Plastic Surgery Hospital Program answer to: At the beginning of each ASP file use <% @LANGUAGE =vbscript%> code is used to inform the server is now using VBScript to write programs, but because the ASP's default program language is VBScript, Therefore, ignoring this code can also work, but if the script language of the program is Javascrip, you need to indicate the scripting language used in the first line of the program.
9. Question: Do I need to use "Option Explicit" in each ASP file?
A: In practice, the concept of VBScript variables is blurred, allowing direct use of variables instead of Dim declaration variables, but this is not a good habit and is prone to program errors because a variable can be defined repeatedly. We can use the Option Explicit statement in the program so that when a variable is used, it must be declared, and if it is run with a variable that is not declared, the program will go wrong.
The practice proves that the use of "Option Explicit" in ASP files can minimize the chance of program error and greatly improve overall performance.
10. Question: What security measures are available when running ASP files?
A: ASP provides a good code protection mechanism, all ASP code is executed on the server side and only return to the client code execution results. But still do not rule out malicious people on the Web server deliberately destroyed, so in writing ASP files more attention to security issues.
Although the introduction of files with Inc as an extension in ASP, it is still recommended to use ASP as an extension of the citation file. When the code runs on a poorly secured Web server, simply enter the address of the introduction file on the Address Bar (inc is the extension) to browse the contents of the ingest file, because on the Web server, if there is no dynamic connection library defined to parse a type (such as Inc), The file is displayed in Source mode.
In addition, do not put the database file inside the structure of the site, so that when the malicious person to obtain the database path, it can easily obtain the database, and then arbitrarily change the database content. It is a good practice to establish a data source name DSN (Date source name) for the database, which stores information about the connection to the specified data provider in the DSN, including: "The physical location of the database, the type of driver used to access the database, Any additional parameters required to access the driver for the database ", you can access the DSN directly during database access.
11. Question: What should I consider when commenting on Web database management system?
A: When evaluating a Web database management system, three aspects of the problem must be taken into account: multi-user issues, the Web database should be relational, and the security of the database.
12. Question: What is ADO and how does it operate the database?
A: The full name of ADO is an ActiveX data object, an optimized set of dedicated objects that access the database, providing the ASP with a complete site database solution that acts on the server side, providing the content of the home page containing the database information. By executing the SQL command, let the user enter, update and delete the site database information in the browser screen.
ADO mainly includes Connection,recordset and command three objects, their main functions are as follows:
· Connection object: Responsible for opening or connecting the database file;
· Recordset object: Access the contents of the database;
· Command object: Release an action query instruction to the database, and execute the SQL Server stored procedure.
13. Question: Where is the difference between using the Recordset object and the Command object to access the database?
Shenyang 463 Plastic Surgery Hospital Procedure A: The Recordset object will require the database to transfer all the data, then the large amount of data will cause the network congestion and the load of the database server is too heavy, so the overall execution efficiency will be reduced.
Using the Command object to invoke the SQL statement directly, the operation is performed on the database server, and there is obviously a high level of execution efficiency. In particular, the server-side execution of the creation of the completed stored procedures, can reduce network traffic, in addition, due to the prior syntax analysis, can improve the overall efficiency of execution.
14. Question: Do I have to create a connection object for each Recordset object?
A: You can use the same connection object for different Recordset objects at the same time to conserve resources.
15. Question: What is a database management system (DBMS)?
A: In order to ensure the security and consistency of the data stored in the database, a set of software is required to complete the corresponding management tasks, this group of software is a database management system, referred to as Dbms,dbms with the system of different, but generally speaking, it should include the following aspects of the content:
Database Description Function: Define the global logical structure of the database, local logical structure and various other database objects;
Database management functions: including system configuration and management, data access and update management, data integrity management and data security management;
database query and Manipulation functions: This function includes database retrieval and modification;
Database maintenance functions: Including data introduction and management, database structure maintenance, data recovery function and performance monitoring.
In order to improve the efficiency of database system development, modern database system provides various tools to support application development in addition to DBMS.
16. Question: What is the current popular web database management system?
A: The current popular web database management system has Microsoft SQL Server, Oracle, DB2, Sybase, small-scale enterprises use access.
17. Question: What is the difference between using the AddNew method of ADO in ASP and directly using the "Insert into ..." statement? Which Way is better?
A: The AddNew method of ADO only encapsulates the "Insert into" statement, so when working with large amounts of data, using SQL statements directly will greatly speed up access to the data because it reduces the "translation" Time of ADO, Because SQL statements perform operations directly on the database server, there is a significant advantage when the volume of data is large.
18. Question: Why do I use standard Insert record statements in ASP insert into books (Name,email) VALUES ("Kitty", "[email protected]") error?
A: SQL (structured Query language/) is the data query language developed by IBM in the 1970 's, which has now become the standard of relational database query language. The SQL statement is an English-based programming language that you can use to add, manage, and Access databases.
When you add a string in an SQL statement, you can use double quotation marks, but you need to use single quotes in ASP to perform normally. So it should be written as insert into books (Name,email) VALUES (' Kitty ', ' [email protected] ').
19. Question: What is an ActiveX control? Where can I get these ActiveX controls?
A: Microsoft ActiveX controls are reusable software components developed by a software provider. In addition to ASP embedded objects, in addition to the installation of ActiveX control can also be used in ASP, this can save a lot of valuable development time, in the ASP is actually embedded a lot of ActiveX control can be used.
With ActiveX controls, you can quickly add special features to your Web applications, as well as your development tools. For example, use the AdRotator object to make an ad scroll board, use the FileSystemObject object for file access, and use the marquee object to implement scrolling text.
Now, there are more than 1000 commercially available ActiveX controls, and the development of ActiveX controls can be used in a variety of programming languages, such as C,c++, and Microsoft Visual J + + for the Visual Java development environment. Once the ActiveX control has been developed, the design and developer can use it as a pre-assembled component for developing client programs. Using ActiveX controls in this way, users do not need to know how these components are developed, and in many cases, they do not even have to do their own programming to complete the design of a Web page or application.
There are more than 1000 types of commercial controls currently available from third-party software developers. The Microsoft ActiveX component Library (ActiveX Component Gallery) has information and related connections that point to the various ActiveX controls provided by Microsoft and third-party developers. In the Microsoft ActiveX Components Library (ActiveX Component Gallery), you can find a list of companies that develop Internet-enhanced ActiveX controls.
20. Question: Why do I use strstartport= ("catmenu_0") statement to get the value of the starting site in the form that is not found in the database?
A: This is because the value of the starting site may have a space, such as the original intention is "Hangzhou", but because of the space exists, the value of the ASP program may be "Hangzhou", and the database only "Hangzhou" record, of course, can not find, the solution is to use the TRIM function to remove both ends of the string, The corresponding statement is:
Strstartport=trim (Request.Form ("Catmenu_0"))
21, Problem: In ASP, when the life cycle of the variable is over, there are several ways to preserve the variable content?
A: Any action that causes the end of the page, such as pressing the browser's refresh button, or closing the browser and reopening it, will result in the end of the life cycle of the variable.
If you want to preserve the contents of a variable when the page finishes execution, you can use the Application object for the next execution. For example, you can use the Application object to create a counter to the statistics website traffic.
The session object, like the Application object, can store the contents of the variable at the end of the page, but unlike the Application object, each online is a separate session object. Simply put, all online Internet users will only share a Application object, but each online surfer will have their own session object.
The Application object and Session object can help us to record information on the server side, while the cookie object will use the cookie function provided by the browser to record the information on the client. One thing to note is that cookies are information that is recorded in the browser, so that data access is not as simple as accessing other ASP objects (information stored on the server side), and actually running, only when the browser starts browsing a Web page of server, The browser is not able to exchange cookies with the server until the server has downloaded any data to the browser.
22. Question: What should I do when I finish using the object?
A: When you finish using the object, first use the Close method to free the system resources that the object occupies, and then set the object value to "nothing" to free up the memory used by the object, or else the Web Service site will run less efficiently or even crash because of too many objects, the corresponding statement is as follows:
23. Problem: There are several ways to read HTML form fields in an ASP file.
A: The Request object can read the contents of an HTML form field in addition to the parameters that are attached to the URL, often using the following syntax structure:
< Form >
The method can accept get or post two transmission methods, wherein the post is to allow the transfer of large amounts of data, and the Get method will be transferred to the data behind the URL, and then sent to the server together, so the amount of data transferred will be limited. But the execution efficiency is better than the Post method.
Data can be sent to the server using the Get or post method, and the corresponding method of receiving data using the Request object is as follows:
Get:Request.QueryString ("field name") can also be written as Request ("Field name")
Post:Request.Form ("field name") can also be written as Request ("Field name")
24. Question: How can I improve the efficiency of using the request collection?
A: When using the Request collection, this is much slower than accessing a local variable because it contains a series of searches for the associated collection. Therefore, if you intend to use a value from the request collection more than once in a page, you should consider storing it as a local variable.
25. Question: Can I use VBScript in the ASP page or use JScript to mix the scripting engine?
A: Although you can use VBScript in an ASP page, you can also use JScript. However, it is not advisable to use both JScript and VBScript on the same page. Because the server has to instantiate and attempt to cache two (rather than one) scripting engines, this increases the system burden to a certain extent. Therefore, for performance reasons, you should not mix multiple scripting engines on the same page.
26. Problem: When we create an ASP file and conform to the syntax, enter the following address through the browser, or open browse through Explorer: c:\inetpub\wwwroot\ A.asp, there will be an error that cannot be run, and if the permissions are incorrect or the file cannot be accessed, why can't I run the ASP file properly?
A: This is because the ASP file first requires the site to have the "execute (script)" attribute, and then asks to enter the address in the URL format, rather than the DOS format, we need to install and start the Web service platform on the computer, and ensure that the ASP file is stored in the Web server virtual directory, Can be browsed through the format of HTTP, in the browser's address bar type: "/HTTP/web site name (or the site's IP address)/asp file name", enter after you can see the server in the browser to execute the ASP file results.
27. Question: What is ASP? What does it have to do with ASP?
A: Active Server Pages (ASP, Active Server Pages) is a relatively simple programming environment in which you can mix HTML, scripting language, and a few components to create server-side Internet applications;
Asp. NET is a powerful programming environment powered by Microsoft, which can be used to create Web-based applications using a variety of high-level languages such as C # and scripting languages, HTML, XML, XSL, and more. Asp. NET regards C # as an object-oriented language, in many ways C # will become Microsoft's Java-like language. C # is one of the most important features of ASP. Microsoft will develop C # as a powerful opponent of Java. This is also Microsoft. NET Framework is an important component. I think C # is the main tool for Microsoft to defeat its opponents in the programming language field.
Asp. NET in object-oriented, database connectivity, large site applications and other aspects are better than ASP programs, ASP. NET also provides additional new features such as built-in object caching and page result caching, built-in XML support for simple processing of XML datasets, and server control that provides a more fully interactive system.
Asp. NET is still completely locked down in Microsoft's operating system, to really play the ASP, you have to use C # or vb.net. These two languages will become the core scripting language of the ASP.
ASP Programming Example: ASP Design FAQs and Answers essentials