Q: Why does the RecordCount value of my recordset always return -1?
Answer: You should use this mode to open the recordset for accessing the database:
rec.openstrSQL,conn,1,1
Among them, strSQL is the SQL statement to operate the database; conn is the Connection variable to connect to the database.
Question: I have written a lot of comments in the ASP script. Will this affect the speed of the server processing ASP files?
Answer: After testing by foreign technical personnel, the overall performance of ASP files with too many comments will only decrease by 0.1%, which means that it will basically not affect the performance of the server.
Q: Do I need to use it at the beginning of every ASP file?
Answer: If the scripting language you are using is VBScript, please 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 language, please use this statement.
Q: Do I need to use OptionExplicit in every ASP file?
Answer: You'd better do this, because this can minimize the chance of errors in your program and improve the overall performance by nearly 9.8%.
Question: What are the new features of ASP3.0 that recently appeared with IIS5.0?
Answer: In fact, there are no new changes, but two new methods of the Server object have been added:
Server.Transfer and Server.Excute, and a new object ASPError. For specific usage instructions, please refer to Microsoft’s website www.microsoft.com
Question: Why do I get errors when using Response.Redirect?
Answer: The most common reason is that you modified the HTTP header after writing the page. The solution is to write at the beginning of the page
Question: It seems that the Redirect method can only redirect to the same frame. Can it be redirected to other frames?
Answer: Yes, you need to add this:. Then, when you use
When calling the Redirect method, it will be redirected to the frame named FrameName.
Question: Why do sessions often appear lost in the ASP pages of new windows I open using the Window.open() method?
Answer: This situation often occurs in Microsoft's IE4.x, but this error has been solved in IE5.x. Therefore, in order to be compatible with all browsers, you can use methods such as test.asp?name=xxx to pass parameters between windows. This effect is better. Just be aware that if the parameters passed are very important, please do not use it. Pass it in clear text, otherwise it will easily lead to security issues.
Question: It is often seen that there are two ways to connect to the database, DSN and DSN-LESS. What do they mean? Is there any difference?
Answer: DSN is the abbreviation of English DataSourceName. The DSN method is the connection method of data source. This data source can be set in ODBCDataSources in the control panel, and then used like this:
Conn.OpenDSN=Test;UID=Admin;PWD=;
The Test is the name of the data source you set yourself. Note that you must use UID and PWD at the same time, otherwise an error will occur.
Similarly, DSN-LESS is a non-data source connection method. The usage method is:
Conn.OpenDriver={MicrosoftAccessDriver
(*.mdb)};Dbq=/somepath/mydb.mdb;Uid=Admin;Pwd=;
Under the same hardware environment, the DSN-LESS method has higher performance than the DSN method. However, once the ASP source code is leaked by others due to certain security issues, the database account and password will be leaked, so these two methods There are pros and cons.
Question: Is there any difference between using ADO's AddNew method in ASP and directly using the Insertinto... statement? Which way is better?
Answer: ADO's AddNew method only encapsulates the Insertinto statement. Therefore, when operating on a large amount of data, directly using SQL statements 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 and other statements, it is very important to learn some commonly used SQL statements in database programming.
Question: Why does an error occur when I insert this sentence (Let'sgonow!) into the database?
Answer: Because most databases (Access, MSSQLServer) use single quotes as delimiters, you cannot directly insert single quotes into the database. You must replace each single quote before executing the SQL statement. into two single quotes:
MyData=Replace(MyData,','',1) Then, just save it to the database
1. Question: Is ASP a programming language?
Answer: ASP is not a programming language, but a development environment. ASP provides an environment for executing instructions on the server side. It uses special symbols () to distinguish HTML from commands that must be translated by the server before being sent to the client. The instructions it can execute include HTML language, MicrosoftVBScript and MicrosoftJscript, etc., so it can make powerful web applications.
2. Question: Can PWS be used to host multiple Web sites on a Web server?
Answer: Only one Web site can be accommodated on the PWS. In order to host multiple Web sites on the same computer, you need to use Windows NT Server or Windows 2000 Server/Professional and IIS.
3. Question: How to use the 6 built-in ASP objects?
Answer: ASP provides multiple embedded objects, which can be directly accessed and used in instructions without creating them. These six objects mainly include: Request object, Response object, Session object, Application object, Server object, Cookies object, the Server object among these six objects can load other components, which can extend the functions of ASP.
The life cycle of an object created using Server.CreateObject begins when it is created and ends when the web page program in which it is located ends. If you want the object to be used across web pages, you can use the Session object to record the object created by Server.CreateObject.
4. Question: Why does the following error occur when using Response.Redirect: wrong title, the HTTP title has been written to the client browser, and any modification to the HTTP title must be made before writing the page content?
Answer: Response.Redirect can transfer a web page to another web page. The syntax structure used is as follows: Response.Redirect URL, where the URL can be a relative address or an absolute address, but it is used in IIS4.0 and IIS5.0. There is a difference.
Transferring web pages in IIS4.0 must be performed before any data is output to the client browser, otherwise an error will occur. The so-called data here includes HTML tags, such as:, etc., which have been improved in IIS5.0. The buffer is enabled by default in IIS5.0, and such errors no longer occur.
There is a Buffer attribute in the Response object. This attribute can set whether the website will transmit data to the client immediately after processing the ASP, but this attribute must also be set before transmitting any data to the client.
To be on the safe side, no matter what ASP running platform is used, set the buffer to open at the beginning of the page so that such an error will not occur.
5. Question: Does buffered output have any impact on web page transmission?
Answer: In relatively large Web pages, there may be some delay in the first part appearing in the browser, but loading the entire Web page is faster than without buffering.
6. Question: Can the Request.QueryString collection be used to query the string value when no form is submitted?
Answer: The Request object is used to read browser data. In addition to reading the contents of form fields, it can also be used to read the parameters attached to the URL. No matter how the request string is added to the link address, for Request There is no difference. You can use the Request.QueryString collection to submit a form using the get method, or to follow a link with an additional query string to query all the values in the string.
7. Question: I wrote a lot of comments in the ASP script. Will this affect the speed of the server processing ASP files?
Answer: In the process of writing a program, it is a good habit to make comments. Tested by foreign technicians, the overall performance of ASP files with too many comments will only drop by 0.1%, which means that in actual applications, the performance of the server will basically not be felt to drop.
8. Question: Do I need to use it at the beginning of each ASP file?
Answer: The code used at the beginning of each ASP file is used to inform the server that VBScript is now used to write the program. However, because the default programming language of ASP is VBScript, it can run normally even if the code is ignored. However, if the script language of the program is With JavaScript, you need to specify the scripting language used in the first line of the program.
9. Question: Do I need to use OptionExplicit in every ASP file? Answer: In practical applications, the concept of VBScript variables has been blurred, allowing variables to be used directly without using Dim to declare variables. However, this is not a good habit and can easily cause program errors because a variable may be defined repeatedly. We can use the OptionExplicit statement in the program, so that when using a variable, it must be declared first. If an undeclared variable is used, the program will error during runtime.
Practice has proven that using OptionExplicit in ASP files can minimize the chance of program errors and greatly improve overall performance.
10. Question: What are the security measures when running ASP files?
Answer: ASP provides a good code protection mechanism. All ASP codes are executed on the server side and only the execution results of the client code are returned. However, it is still not ruled out that malicious people can deliberately damage the Web server, so you should pay more attention to security issues when writing ASP files.
Although files imported in ASP use inc as the extension, it is still recommended to use ASP as the extension of the imported file. When these codes are run on a WebServer with poor security mechanism, you only need to enter the address of the imported file in the address bar (inc is the extension), and you can browse the content of the imported file. This is because on the WebServer, if there is no When a dynamic link library that parses a certain type (such as inc) is defined, the file is displayed in source code mode.
In addition, do not place the database file inside the website structure. In this way, when a malicious person obtains the database path, they can easily obtain the database and then change the database content arbitrarily. A better approach is to establish a data source name DSN (DateSourceName) for the database. Information about connecting to the specified data provider is stored in the DSN, including: the physical location of the database, the type of driver used to access the database, access Any other parameters required by the database driver can be accessed directly from the DSN during database access.
11. Question: What issues should be considered when evaluating a Web database management system?
Answer: When evaluating a Web database management system, three issues must be considered: multi-user issues; the Web database established should be relational; and database security issues. 12. Question: What is ADO and how does it operate the database?
12. Question: What is ADO and how does it operate the database?
Answer: The full name of ADO is ActiveXDataObject (ActiveX Data Object), which is a set of specialized objects optimized for accessing databases. It provides a complete site database solution for ASP. It acts on the server side and provides a homepage containing database information. Content, by executing SQL commands, allows users to enter, update and delete information in the site database in the browser screen.
ADO mainly includes three objects: Connection, Recordset and Command. Their main functions are as follows:
·Connection object: responsible for opening or connecting to database files;
·Recordset object: access the contents of the database;
·Command object: issues action query instructions to the database and executes SQL Server stored procedures.
13. Question: What is the difference between using Recordset object and Command object to access the database?
Answer: The Recordset object will require the database to transmit all data. When the amount of data is large, it will cause network congestion and overload the database server, so the overall execution efficiency will be reduced.
Using the Command object to directly call SQL statements, the operations performed are performed in the database server, which obviously has high execution efficiency. In particular, executing the created stored procedure on the server side can reduce network traffic. In addition, since syntax analysis is performed in advance, the overall execution efficiency can be improved.
14. Question: Is it necessary to create a Connection object for each Recordset object?
Answer: You can use the same Connection object for different Recordset objects at the same time to save resources.
15. Question: What is a database management system (DBMS)?
Answer: In order to ensure the security and consistency of the data stored in the database, the database must have a set of software to complete the corresponding management tasks. This set of software is the database management system, or DBMS for short. The DBMS varies with the system, but generally speaking, It should include the following aspects:
Database description function: Define the global logical structure, local logical structure and other various 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 functions: This function includes database retrieval and modification;
Database maintenance functions: including data import and export management, database structure maintenance, data recovery functions and performance monitoring.
In order to improve the development efficiency of database systems, modern database systems also provide various tools to support application development in addition to DBMS.
16. Question: What are the currently popular WEB database management systems?
Answer: Currently popular web database management systems include Microsoft's SQL Server, Oracle, DB2, and Sybase. Small-scale enterprises mostly use Access.
17. Question: What is the difference between using ADO's AddNew method and directly using the Insertinto... statement in ASP? Which way is better?
Answer: ADO's AddNew method only encapsulates the Insertinto statement. Therefore, when operating on a large amount of data, directly using SQL statements will greatly speed up data access because it reduces the translation time of ADO. Due to SQL The operations performed by the statement are performed directly in the database server, which has significant advantages especially when the amount of data is large.
18. Question: Why do I get an error when I use the standard insert record statement insertintobooks(name,email)values(kitty,[email protected]) in ASP?
Answer: SQL (StructuredQueryLanguage/Structured Query Language) is a data query language developed by IBM in the 1970s. It has now become the standard for relational database query languages. SQL statements are an English-based programming language that can be used to add, manage, and access databases.
Although you can use double quotes when adding a string in a SQL statement, single quotes are required in ASP for normal execution. So it should be written insertintobooks(name,email)values('kitty','[email protected]').
19. Question: What are ActiveX controls? Where can I get these ActiveX controls?
Answer: Microsoft ActiveX controls are reusable software components developed by software providers. In addition to the embedded objects of ASP, the installed ActiveX controls can also be used in ASP, which can save a lot of valuable development time. In fact, there are also many ActiveX controls embedded in ASP that can be used.
Using ActiveX controls, special functions can be quickly added to Web applications and development tools. For example, use the AdRotator object to create an advertising scrolling board, use the FileSystemObject object for file access, and use the Marquee object to implement scrolling text.
Now, there are more than 1,000 commercial ActiveX controls. ActiveX controls can be developed using various programming languages, such as C, C++, etc., as well as Microsoft's VisualJava development environment MicrosoftVisualJ++. Once an ActiveX control is developed, designers and developers can use it as a preassembled component for developing client programs. Using ActiveX controls in this way, users do not need to know how these components are developed. In many cases, they do not even need to program themselves to complete the design of web pages or applications.
There are currently more than 1,000 commercial controls provided by third-party software developers. Microsoft ActiveX Component Gallery (ActiveXComponentGallery) stores relevant information and related links, which point to various ActiveX controls provided by Microsoft and third-party developers. In the Microsoft ActiveX Component Gallery (ActiveXComponentGallery), you can find a list of companies that develop Internet-enhanced ActiveX controls.
20. Question: Why can’t the value of the starting site in the form be found in the database using the strStartPort=(Request.Form(catmenu_0) statement?
Answer: This is because the value of the starting site obtained may have spaces. For example, the original meaning is Hangzhou. However, due to the existence of spaces, the value obtained by the ASP program may be Hangzhou, and there are only records of Hangzhou in the database. Of course, it 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: In ASP, when the life cycle of a variable ends, how many methods are there to retain the content of the variable?
Answer: Any operation that causes the end of the web page, such as pressing the browser's refresh button, or closing the browser and then reopening it, will cause the end of the variable life cycle.
If you want to retain the contents of variables when the web page ends execution for use in the next execution, you can use the Application object to achieve this. For example, you can use the Application object to create a counter that counts website visits.
The Session object is the same as the Application object. It can store the contents of the variable at the end of the web page. However, unlike the Application object, each connection is an independent Session object. Simply put, all online users will only share one Application. object, but each online user will have his or her own Session object.
The Application object and Session object can help us record information on the server side, while the Cookies object will use the Cookies function provided by the browser to record information on the client side. One thing to note is that cookies are information recorded in the browser, so data access is not as simple as accessing other ASP objects (information is stored on the server side). In terms of actual operation, only when the browser starts browsing the server A certain web page, and the server has not downloaded any data to the browser before the browser can exchange Cookies data with the server.
22. Question: What should you do after using the object?
Answer: After using the object, first use the Close method to release the system resources occupied by the object; then set the object value to nothing to release the memory occupied by the object. Otherwise, the operating efficiency of the WEB service site will be reduced or even crashed due to too many objects. The corresponding statements are as follows:
23. Question: How many methods are there to read HTML form fields in ASP files?
Answer: In addition to reading the parameters attached to the URL, the Request object can also read the contents of HTML form fields. The commonly used syntax structure is as follows:
The method can accept two transmission methods: Get or Post. Post is a method that allows the transmission of large amounts of data. The Get method will attach the data to be transmitted to the end of the URL and then send it to the server together, so the amount of data transmitted is It will be restricted, but the execution efficiency is better than the Post method.
Data can be sent to the server using the Get or Post method. The corresponding methods for receiving data using the Request object are 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 to improve the efficiency of using the Request collection?
Answer: When using the Request collection, it is much slower than accessing a local variable because it involves a series of searches for related collections. Therefore, if you plan to use a value in the Request collection multiple times on the page, you should consider storing it as a local variable.
25. Question: Both VBScript and Jscript can be used in ASP pages. Is it good to use a mixed script engine?
Answer: Although both VBScript and JScript can be used in ASP pages. But it is not advisable to use JScript and VBScript at the same time on the same page. Because the server must instantiate and attempt to cache two (rather than one) script engines, this increases the load on the system to some extent. Therefore, for performance reasons, you should not mix multiple script engines on the same page.
26. Question: When we create an ASP file and it conforms to the syntax, if we enter the following address through the browser, or open it through the resource manager and browse: c:/inetpub/wwwroot/a.asp, an inoperable error will appear. It prompts that the permissions are incorrect or the file cannot be accessed. Why can't the ASP file run normally?
Answer: This is because the ASP file first requires the site to have execution (script) attributes; and then requires the address to be entered in URL format instead of 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 virtual directory of the Web server, you can browse in HTTP format. In the address bar of the browser, enter: http://Web site name (or IP address of the site)/ASP file name, and press Enter to browse. The result of the server executing the ASP file is seen in the browser.
27. Question: What is ASP.NET? What does it have to do with ASP?
Answer: ActiveServerPages (ASP, Active Server Pages) is a relatively simple programming environment in which HTML, scripting languages and a small number of components can be mixed to create server-side Internet applications;
ASP.NET is a powerful programming environment promoted by Microsoft. It can use a variety of high-level languages such as C# and scripting languages, HTML, XML, XSL, etc. to create network-based applications. ASP.NET uses C# as an object-oriented language. In many ways, C# will become Microsoft's language similar to Java. C# is one of the most important features in ASP.NET development, and Microsoft will develop C# into a strong rival to Java. This is also an important part of Microsoft's .Net framework. I think C# is Microsoft's main tool to defeat its rivals in the programming language space.
ASP.NET is superior to ASP programs in terms of object orientation, database connection, large-scale site applications, etc. ASP.NET also provides more new features in other aspects, such as: built-in object caching and page result caching; built-in XML Supported, can be used for simple processing of XML data sets; server control provides more complete interactive control, etc.
ASP.NET is still completely locked into Microsoft's operating system. To truly realize the potential of ASP.NET, you have to use C# or vb.net. These two languages will become the core scripting languages of the ASP.NET standard.