Asp q & A set

Source: Internet
Author: User
Tags web database what is asp

Q: Why does my RecordCount always return-1?
A: You should use this mode to open the record set for database access:
Rec. open strSQL, conn, 1, 1
StrSQL is the SQL statement used to operate the database, and conn is the Connection variable used to connect to the database.
Q: I wrote a lot of comments in the ASP script. Will this affect the server's processing speed of ASP files?
A: According to tests by foreign technicians, the overall performance of ASP files with too many comments only drops by 0.1%, that is, the performance of the server is basically not affected.
Q: Do I need to start with an ASP file?
A: If you use VBScript, try not to use this statement. Otherwise, the overall performance of the program will be reduced by nearly 1.2%. However, if you are not using VBScript, use this statement.
Q: Do I need to use "Option Explicit" in every ASP file "?
A: You 'd better do this because it can minimize the chance of program errors and improve the overall performance by nearly 9.8%.
Q: What are the new functions of ASP3.0 that have recently appeared along with IIS5.0?
A: Actually, there are no new changes, but there are two new methods for adding Server objects:
Server. Transfer and Server. Excute, and a new object ASPError. For more information, see
Q: Why does an error occur when I use Response. Redirect?
A: The most common reason is that you have modified the HTTP title after writing the page. The solution is to write the title at the beginning of the page.
Q: It seems that the Redirect method can only Redirect to the same frame. Can it Redirect to another frame?
A: Yes. add this :. Then, when you use
The Redirect method will Redirect to the frame named FrameName.
Q: Why is Session loss often occurring on ASP pages of new windows opened by the "Window. open ()" method?
A: This problem often occurs in Microsoft IE4.x, but this error has been fixed in IE5.x. Therefore, to be compatible with all browsers, you can use? Name = xxx "is used to pass parameters between windows. This effect is better, but note that if the transmitted parameters are very important, do not use Plaintext for transmission, otherwise, security issues may easily occur.
Q: I often see that there are two ways to connect to the database DSN and DSN-LESS, what do they mean? Is there any difference?
A: DSN is the abbreviation of "Data Source Name". The DSN mode is the Data Source connection mode, this Data source can be set in "ODBC Data Sources" in "Control Panel", and then used as follows:
Conn. Open "DSN = Test; UID = Admin; PWD = ;"
The "Test" is the name of the data source you set. Note: UID and PWD must be used at the same time; otherwise, an error will occur.
Similarly, a DSN-LESS is a join method that is not a data source, using:
Conn. Open "Driver = {Microsoft Access Driver
(*. Mdb)}; Dbq = \ somepath \ mydb. mdb; Uid = Admin; Pwd = ;"
In the same hardware environment, the DSN-LESS mode is higher than the DSN mode, but once the ASP source code is caused by some security issues, the account and password of the database will be leaked, so these two methods have advantages and disadvantages.
Q: Is there a difference between using the AddNew method of ADO in ASP and directly using the "Insert into..." statement? Which method is better?
A: The AddNew method of ADO only encapsulates the "Insert into" statement. Therefore, when operating a large amount of data, using SQL statements directly will greatly speed up data access, because it reduces the "Translation" time of ADO. Although SQL statements are not as easy to accept as AddNew statements, it is very important to learn some common SQL statements for database programming.
Q: Why do I use this sentence ("Let's go now !") Will an error occur when you insert it into the database?
A: Because most databases (Access, ms SQL Server) use single quotes as separator, so you cannot directly insert single quotes into the database, you must replace each single quotation mark with two single quotation marks before executing the SQL statement:
MyData = Replace (MyData, "'", "'' ", 1) and then save it to the database.
1. Question: Is ASP a programming language?
A: ASP is not a programming language, but a development environment. ASP provides an environment for executing commands on the server. It uses special symbols () to distinguish between HTML and commands that can be sent to the client only after being translated by the server. It can execute commands such as HTML, Microsoft VBScript, and Microsoft Jscript, so it can produce powerful Web applications.
   2. Question: Can I use PWS to accommodate multiple Web sites on a Web server?
A: Only one Web site can be accommodated on PWS. To accommodate multiple Web sites on the same computer, you need to use Windows NT Server, Windows 2000 Server/Professional, and IIS.
   3. Question: How to use six built-in ASP objects?
A: ASP provides multiple embedded objects that can be directly accessed and used in commands without being created. These six objects are mainly Request objects and Response objects) objects, Session objects, Application objects, Server objects, and Cookies objects. Other components can be loaded on the Server objects of these six objects, this can expand ASP functions.
The object created using Server. CreateObject. its lifecycle starts when it is created and ends when its webpage program ends. If you want this object to be used across webpages, you can use the Session object to record the objects created by Server. CreateObject.
   4. Question: Why is Response used. during Redirect, the following error occurs: "The title is incorrect. The HTTP title has been written to the client browser. Any changes to the HTTP title must be made before the page content is written "?
A: Response. redirect can transfer a webpage to another webpage. The syntax structure is as follows: Response. redirect URL. The URL can be a relative address or an absolute address, but it is different in IIS4.0 and IIS5.0.
An error occurs when IIS4.0 transfers a webpage before any data is output to the client browser. Here, the so-called data includes HTML labels, such as:, and so on, and has been improved in IIS5.0. By default, the buffer zone is enabled in IIS5.0, and such errors are not generated.
There is a Buffer attribute in the Response object. This attribute can be used to set whether the website will transmit data to the client immediately after processing ASP. However, this attribute must be set before transmitting any data to the client.
For the sake of insurance, no matter which ASP operating platform is used, write it at the beginning of the page and set the buffer zone to enable. This error will not happen.
   5. Question: Does the buffer output affect webpage transmission?
A: In a large web page, the first part may have some latency in the browser, but loading the entire web page is faster than without buffering.
   6. Question: Can I use the Request. QueryString set to query the string value when no form is submitted?
A: The Request object is used to read data from the browser. In addition to reading the content of form fields, it can also be used to read parameters attached to the URL, no matter how the Request string is added to the link address, the Request is no different. You can use the Request. QueryString collection to submit a form using the get method or to query all values of a string following the link of an additional query string.
   7. Question: I wrote a lot of comments in the ASP script. Will this affect the server's processing speed of ASP files?
A: It is a good habit to annotate a program. Tested by foreign technical staff, the overall performance of ASP files with too many comments will only drop by 0.1%, that is to say, the performance of the server will not be decreased in actual applications.
   8. Question: Do I need to use it at the beginning of each ASP file?
A: The code used at the beginning of each ASP file is used to notify the server that VBScript is used to write programs. However, because the default programming language of ASP is VBScript, the code can also run normally, however, if the scripting language of the program is JavaScrip, You need to specify the scripting language used in the first line of the program.
9. Question: Do I need to use "Option Explicit" in every ASP file "? A: in practical applications, the VBScript variable concept has been vague, allowing direct use of variables without the need for Dim to declare variables. However, this is not a good habit and may cause program errors, because a variable may be defined repeatedly. We can use the Option Explicit statement in the program. When using a variable, we must declare it first. If no declared variable is used, an error occurs during running.
Practice has proved that using "Option Explicit" in ASP files can minimize program error opportunities and greatly improve overall performance.
   10. Question: What are the security measures for running ASP files?
A: ASP provides a good code protection mechanism. All ASP code is executed on the server and only returned to the client for code execution. However, it still does not rule out the deliberate destruction of Web servers by malicious people. Therefore, you must pay attention to security issues when writing ASP files.
Although inc is introduced in ASP, it is recommended that ASP be used as the extension of the cited file. When these codes run on a Web Server with poor security mechanisms, you only need to enter the address of the introduced file (inc is the extension) in the address bar to view the content of the introduced file, this is because on the Web Server, if the dynamic Connection Library of a certain type (such as inc) is not defined, the file is displayed as source code.
In addition, do not place database files inside the website structure. In this way, when attackers obtain the database path, they can easily obtain the database and modify the database content. A good practice is to create a data Source Name DSN (Date Source Name) for the database, and store information about the connection to the specified data provider in DSN, including: "Physical location of the database, the type of the driver used to access the database. Any other parameters required by the driver used to access the database. "You can directly access the DSN when accessing the database.
   11. Question: Which questions should I consider when reviewing the Web Database Management System?
A: When evaluating a Web database management system, three problems must be taken into account: multi-user problems; the Web database established should be relational databases; and database security problems. 12. Question: What is ADO and how does it operate databases?
   12. Question: What is ADO and how does it operate databases?
A: The full name of ADO is ActiveX Data Object (ActiveX Data Object). It is a special set of optimized database access objects. It provides ASP with a complete site database solution, it serves on the server and provides the homepage content containing database information. By executing SQL commands, users can enter, update, and delete information about the site database in the browser screen.
ADO mainly includes three objects: Connection, Recordset, and Command. Their main functions are as follows:
· Connection object: opens or connects to database files;
· Recordset object: access the database content;
· Command object: give action query commands to databases and execute the stored procedures of SQL Server.
   13. Question: What is the difference between using A Recordset object and a Command object to access the database?
A: The Recordset object requires the database to transmit all the data. When the data volume is large, network congestion and heavy load on the database server will occur. Therefore, the overall execution efficiency will be reduced.
The Command object is used to directly call SQL statements. The operations executed are performed on the database server, which is obviously very efficient. In particular, executing the created storage process on the server can reduce network traffic. In addition, syntax analysis can improve the overall execution efficiency.
   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 to save resources.
   15. Question: What is a database management system (DBMS )?
A: To ensure the security and consistency of the data stored in the database, a group of software must be provided to complete corresponding management tasks. This group of software is the database management system (DBMS for short, DBMS varies with the system, but in general, it should include the following aspects:
Database Description: defines the global logical structure, local logical structure, and other database objects of the database;
Database management functions: including system configuration and management, data access and update management, data integrity management, and data security management;
Database Query and Manipulation: This function includes database retrieval and modification;
Database Maintenance: includes data import and export management, database structure maintenance, data recovery, and performance monitoring.
To improve the development efficiency of database systems, in addition to DBMS, modern database systems also provide a variety of tools to support application development.
   16. Question: What are the popular WEB database management systems?
A: currently, Microsoft SQL Server, Oracle, DB2, and Sybase are popular Web database management systems. Access is widely used in small-scale enterprises.
17. Question: What is the difference between using the AddNew method of ADO in ASP and directly using the "Insert into..." statement? Which method is better?
A: The AddNew method of ADO only encapsulates the "Insert into" statement. Therefore, when operating a large amount of data, the direct use of SQL statements will greatly speed up data access, because it reduces the "Translation" time of ADO, because the operations executed by SQL statements are directly performed on the database server, especially when the data volume is large, it has significant advantages.
   18. Question: Why does an error occur when I use the standard insert record statement insert into books (name, email) values ("kitty", "") in ASP?
A: Structured Query Language (Structured Query Language) is a data Query Language developed by IBM in the 1970 s. It has become a standard for relational database Query Language. An SQL statement is an English-based programming language that can be used to add, manage, and access databases.
Although double quotation marks can be used for strings added to SQL statements, single quotation marks are required in ASP for normal execution. Therefore, insert into books (name, email) values ('Kitty ', 'Kitty @') should be written ').
   19. Question: What is ActiveX Control? Where can I obtain these ActiveX controls?
A: Microsoft ActiveX controls are reusable software components developed by software providers. In addition to ASP embedded objects, ActiveX controls installed can also be used in ASP, which can save a lot of valuable development time, in fact, many ActiveX controls are embedded in ASP.
Using ActiveX controls, you can quickly add special functions to Web applications and development tools. For example, you can use an AdRotator object to create an Ad scroll board, use a FileSystemObject object to access files, and use a Marquee object to implement scroll text.
Currently, there are more than 1000 commercial ActiveX controls. ActiveX controls can be developed in a variety of programming languages, such as C and C ++, and Microsoft Visual Java Development Environment Microsoft Visual J ++. Once the ActiveX control is developed, designers and developers can regard it as a pre-assembly component for developing customer programs. By using ActiveX controls in this way, users do not need to know how these components are developed. In many cases, they can design webpages or applications without programming themselves.
Currently, there are more than 1000 commercial controls provided by third-party software developers. The Microsoft ActiveX Component Library (ActiveX Component Gallery) stores related information and connections, which direct to various ActiveX controls provided by Microsoft and third-party developers. In the Microsoft ActiveX Component Library (ActiveX Component Gallery), you can find a list of companies that develop Internet-enhanced ActiveX controls.

  20. Question: Why can't I find the value of the start site in the Form in the database using the strStartPort = (Request. Form ("catmenu_0") statement?
A: This is because the starting site value may contain spaces. For example, if the origin site is "Hangzhou", but because of the space, the value obtained by ASP may be "Hangzhou ", however, the database only contains records of "Hangzhou", which cannot be found. The solution is to use the Trim function to remove all spaces at both ends of the string. The corresponding statement is:
StrStartPort = TRIM (Request. Form ("catmenu_0 "))
  21. Question: When the lifecycle of a variable ends in ASP, how many methods can be used to retain the variable content?
A: Any operation that causes the web page to end, for example, when you press the "refresh" button of the browser or close the browser and re-open it, the lifecycle of the variable will end.
If you want to retain the variable content at the end of the web page for the next execution, you can use the Application object. For example, you can use the Application object to create a counter for counting website visits.
The Session object is the same as the Application object. The variable content can be stored at the end of the Web page. However, unlike the Application object, each online Session object is an independent Session object, simply put, all online netusers only share one Application object, but each online netuser has its own Session object.
The Application Object and Session object can help us record the information on the server, while the cookie object will record the information on the client through the Cookies function provided by the browser. Note that Cookies are recorded in the browser. Therefore, data access is not as simple as accessing other ASP objects (storing information on the Server, the browser can exchange Cookies with the Server only when the browser starts to browse a webpage of the Server and the Server has not downloaded any data to the browser.
  22. Question: What should I do after the object is used up?
A: After an object is used up, use the Close method to release the system resources occupied by the object, and set the object value to "nothing" to release the memory occupied by the object, otherwise, the website may run less efficiently or even crash due to too many objects. The corresponding statement is as follows:
23. Question: How can I read HTML form fields in an ASP file?
A: The Request object can be used not only to read parameters attached to the URL, but also to read the content of HTML form fields. The syntax structure is as follows:
The method can accept Get or Post transmission methods. The Post method allows transmission of a large amount of data, and the Get method attaches the data to be transmitted to the URL, then it is delivered to the server together, so the amount of data transmitted is limited, but the execution efficiency is better than that of the Post method.
You can send data to the server using the Get or Post method. The method for receiving data using the Request object is as follows:
Get: Request. QueryString ("field name"), which can also be written as Request ("field name ")
Post: Request. Form ("field name"), which can also be written as Request ("field name ")
  24. Question: How can I improve the efficiency of using the Request set?
A: When a Request set is used, it contains a series of searches for related sets, which is much slower than accessing a local variable. Therefore, if you want to use a value in the Request set multiple times on the page, you should consider storing it as a local variable.
  25. Question: Can I use VBScript or Jscript on an ASP page and use the script engine in combination?
A: You can use VBScript or JScript on the ASP page. However, JScript and VBScript cannot be used on the same page at the same time. Because the server must instantiate and try to cache two (rather than one) script engines, which increases the burden on the system to a certain extent. Therefore, in terms of performance, you should not mix multiple script engines on the same page.

  26. Problem: When an ASP file is created and syntactically compliant, enter the following address in the browser or open the browser through the resource manager: c: \ inetpub \ wwwroot \. asp, there will be an error that cannot be run, and the prompt is that the permission is incorrect or the file cannot be accessed. Why can't ASP files run normally?
A: This is because the ASP file requires that the site have the "execute (SCRIPT)" attribute first, and then enter the address in URL format instead of DOS format, we need to install and start the Web Service Platform on the computer, and ensure that ASP files are stored in the virtual directory of the Web server, you can browse through the HTTP format, enter in the address bar of the browser: "http: // Web site name (or site IP address)/ASP File Name", Press enter to view the result of ASP file execution on the server in the browser.
  27. Question: What is ASP. NET? What is the relationship between ASP and ASP?
A: Active Server Pages (ASP, Active Server Pages) is a simple programming environment where HTML, script language, and a few components can be used together to create Internet applications on the Server;
ASP. NET is a powerful programming environment launched by Microsoft. You can use C # and other advanced languages and scripting languages, HTML, XML, and XSL to create network-based applications. ASP. NET regards C # As an object-oriented language. In many aspects, C # will become a language similar to Microsoft and Java. C # is one of the most important functions in ASP. NET development. Microsoft will develop C # into a strong competitor of Java. This is also an important part of the Microsoft. Net Framework. I think C # is the main tool for Microsoft to beat its opponent in the programming language field.
ASP. NET is superior to ASP programs in terms of object-oriented, database connection, and large site applications. ASP. NET also provides more new features, such as built-in object caching and PAGE result caching; built-in XML support, which can be used for simple processing of XML datasets; server Control provides more interactive systems.
ASP. NET is still completely locked in Microsoft's operating system. To realize ASP. NET's potential, you need to use C # Or These two languages will become the core scripting language of ASP. NET standards.

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: 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.