ASP question and Answer set _ programming 10000 Q

Source: Internet
Author: User
Tags comments dsn html form microsoft sql server trim web database what is asp
Q: Why is the RecordCount value of my Recordset always returning-1?
A: You should use this mode to open the recordset that accesses the database:
Rec.open strsql,conn,1,1
The strSQL is the SQL statement that operates the database; conn is the connection variable that joins the database.
Q: I wrote a lot of comments in the ASP script, does this affect the speed at which the server processes ASP files?
A: After testing by foreign technicians, the overall performance of ASP files with too many annotations will only drop by 0.1%, which means that the performance of the server will not be affected.
Q: Do I need to use at the beginning of each ASP file?
A: If you use a scripting language that is VBScript, try not to use this statement, otherwise the overall performance of the program will drop by nearly 1.2%, but if you are not using the VBScript language, please use this statement.
Q: Is it necessary for me to use option Explicit in every ASP file?
A: You'd better do this because it will minimize the chance of your program error and improve overall performance by nearly 9.8%
Q: What are the new features of the ASP3.0 that appeared with IIS5.0 recently?
A: There is no new change, but the new method of adding two server objects:
Server.Transfer and Server.excute, there is also a new object asperror. Please refer to Microsoft's Web www.microsoft.com for specific usage
Q: Why did I get an error when I used Response.Redirect?
A: The most common reason is that you modify the HTTP title after writing the page, and the solution is to write the page at the beginning
Q: It seems that the redirect method can only be redirected to the same frame, could it be directed to other frames?
A: Yes, I'd like to add this:. Then, when you re using
When you redirect the method, you redirect it to the frame named FrameName.
Q: Why do I often see session loss in ASP pages of new windows that I open using the window.open () method?
A: This is often the case in Microsoft's ie4.x, but ie5.x has solved the error. Therefore, in order to be compatible with all browsers, you can use such "test.asp?name=xxx" way to pass parameters between windows, which is better, just note that if the parameters passed are important, do not use plaintext to pass, otherwise it is easy to cause security problems.
Q: It's often seen that there are two ways to connect a database DSN and dsn-less, what do they mean? What's the difference?
A: DSN is the English "data source Name" abbreviation, DSN is the way to use the data source of the join, this data source can be in the "Control Panel" in the "ODBC data Sources" in the set, and then use:
Conn.Open "Dsn=test; Uid=admin; pwd=; "
The "Test" is the name of the data source you set yourself. Note that you can use both the UID and the PWD, otherwise there will be an error.
Similarly, dsn-less is a non-data source method of joining, using the following methods:
Conn.Open "Driver={microsoft Access Driver
(*.mdb)};D Bq=\somepath\mydb.mdb; Uid=admin; pwd=; "
In the same hardware environment, the dsn-less mode is higher than the performance of DSN, but once the ASP source code for some security problems by others, will leak the database account and password, so the two ways is a pros and cons.
Q: Is there a difference between using the AddNew method of ADO in ASP and using the "Insert into ..." statement directly? That's a better way?
A: ADO's AddNew method only encapsulates "Insert into" statement, so when manipulating large amounts of data, direct use of SQL statements will greatly speed up access to data because he reduces the "translation" Time of ADO. Although SQL statements are not as easy to accept as AddNew, it is important to learn some common SQL statements in database programming.
Q: Why do I take this sentence ("Let's Go now!" An error occurs when inserting into the database?
A: Since most databases (Access,ms SQL Server) use single quotes as split symbols, you cannot insert single quotes directly into the database, you must replace each single quotation mark with two single quotes before executing the SQL statement:
Mydata=replace (MyData, "'", "" ", 1) 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 instructions on the server side, which utilizes special symbols () to differentiate between HTML and commands that must be translated by the server before being sent to the client. The instructions that it can execute include the HTML language, Microsoft VBScript, and Microsoft JScript, so you can create powerful Web applications.
   2. Question: Can you use PWS for hosting multiple Web sites on a Web server?
A: 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 to use 6 built-in ASP objects?
A: ASP provides a number of inline objects that can be accessed and used directly in instructions without having to be established, with the following six objects: Request object, Response (Response) object, Session object, application (application) object, Servers (server) objects, cookie objects, server objects in these six objects can load other components, which can extend the functionality of the ASP.
The object created by using Server.CreateObject, its lifecycle begins when it is established, and ends at the end of its web page program. If you want the object to be used across pages, you can use the session object to record the object that Server.CreateObject created.
   4. Question: Why the following error occurred when using Response.Redirect: "Title error, HTTP headers have been written to the client browser, changes to any HTTP headers must be made before the page content is written"?
A: Response.Redirect can transfer the page to another page, using the syntax structure is this: Response.Redirect URL, where the URL can be a relative address or an absolute address, but in IIS4.0 use and in IIS5.0 use is different.
The IIS4.0 Transfer Web page must occur before any data is exported to the client browser, otherwise an error occurs. The so-called data here include HTML labels, such as:, and so on, and in the IIS5.0 has been improved, the IIS5.0 by default, the buffer is open, such errors are no longer generated.
There is a buffer property in the response object that can set whether the Web site will transfer data to the client immediately after processing the ASP, but setting this property must also precede the transfer of any data to the client.
For the sake of insurance, no matter what ASP platform you are running, you can set the buffer to open at the beginning of the page and the error will not happen.
   5. Question: Does the buffer output have any effect on the transmission of the Web page?
A: In a larger web page, the first part may have some latency in the browser, but it is faster to load the entire Web page than not to buffer.
   6. Question: Is it possible to use the Request.QueryString collection when the value of a query string is not submitted by a form?
A: The request object is used to read the browser's data, except that it can read the contents of the form field and can be used to read parameters that come with the URL, regardless of how the request string is added to the link address. You can use the Request.QueryString collection to submit a form using the Get method, or to follow all the values in the linked query string of an additional query string.
   7, the problem: I wrote a lot of comments in the ASP script, this will affect the speed of the server processing ASP files?
A: In the process of writing a program, it is a good habit to make comments. After testing by foreign technicians, the overall performance of an ASP file with too many annotations will only drop by 0.1%, which means that the performance of the server is basically not felt in the actual application.
   8. Question: Do you need to use at the beginning of each ASP file?
A: The code used at the beginning of each ASP file is used to inform the server that it is now using VBScript to write the program, but because the default program language of the ASP is VBScript, ignoring such code can work, but if the script language of the program is Javascrip, You need to specify the scripting language used in the first line of the program.
9. Question: Is it necessary for me to use option Explicit in each ASP file? A: In practice, the concept of VBScript variables is blurred, allowing direct use of variables without the dim declaration of variables, but this is not a good habit, it is easy to cause a program error, because it is possible to repeatedly define a variable. We can use the Option Explicit statement in a program so that when you use a variable, you must declare it, and if you use a variable that is not declared, the program will run into error.
It has been proved that using option Explicit in ASP files can minimize the chance of program error and greatly improve overall performance.
   10. Question: What security measures are there when running ASP files?
A: ASP provides a good code protection mechanism, all ASP code is executed on the server side and only returned to the client code execution results. However, the malicious person does not rule out the deliberate destruction of the Web server, so you should pay more attention to security issues when writing ASP files.
Although the introduction of files in ASP as an extension of INC, ASP is still recommended as the extension of the primer file. When this code is running on a poorly secured Web server, you can browse the contents of the introduced file by simply entering the address of the address bar that introduces the file (inc), because on the Web server, if you do not have a dynamic connection library defined to resolve a type, such as Inc, The file is displayed in Source mode.
In addition, do not put the database files within the structure of the site, so that when the malicious person to obtain the database path, you can easily access 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, where 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, Any additional parameters required to access the database driver, which can be accessed directly from database access.
   11. Question: When evaluating the Web database management system, what problems should be considered?
A: When evaluating a Web database management system, three aspects must be taken into account: multiuser problem; The web database should be a relational type; security of the database. 12. Question: What is ADO, and how does it operate the database?
   12. Question: What is ADO, and how does it operate the database?
A: The full name of ADO is the ActiveX Data Object (ActiveX), an optimized set of dedicated objects to access the database, providing a complete site database solution for the ASP, which functions on the server side, providing the homepage content containing the database information, By executing SQL commands, users are allowed to enter, update, and delete site database information in the browser screen.
ADO mainly includes the Connection,recordset and command three objects, their main functions are as follows:
· Connection object: Responsible for opening or connecting to the database file;
· Recordset object: Accessing the contents of the database;
· Command object: To assign an action query directive to a database, and to execute a stored procedure for SQL Server.
   13. Question: What is the difference between using a Recordset object and a Command object to access a database?
A: The Recordset object will require the database to transfer all the data, then the large amount of data will cause network congestion and the database server overload, so the overall implementation efficiency will be reduced.
Using the Command object to invoke the SQL statement directly, the operations performed are performed on the database server, and are clearly highly efficient. Especially on the server side to perform the creation of 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 save resources by using the same connection object for different Recordset objects at the same time.
   15. Question: What is a database management system (DBMS)?
A: Database in order to ensure that the data stored in the security and consistency, there must be a group of software to complete the corresponding management tasks, this group of software is a database management system, referred to as Dbms,dbms with the different system, but generally speaking, it should include the following aspects:
Database Description Function: Define the global logical structure of the database, local logic structure and other kinds of 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 extraction management, database structure maintenance, data recovery function and performance monitoring.
In order to improve the efficiency of database system development, modern database system, in addition to DBMS, also provides a variety of tools to support application development.
   16, the 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 to use Access more.
17. Question: What is the difference between using the AddNew method of ADO in ASP and using "Insert into ..." statement directly? Which Way is better?
A: The AddNew method of ADO only encapsulates "Insert into" statement, so when manipulating large amounts of data, using SQL statements directly will greatly speed up access to data because it reduces the "translation" Time of ADO. Because the operations performed by SQL statements are performed directly on the database server, they have a significant advantage, especially when the data volume is large.
   18. Question: Why do I use standard Insert record statements in ASP to insert into books (Name,email) VALUES ("Kitty", "kitty@263.com") will be wrong?
A: SQL (structured Query language/Structured Query language) is a data query language developed by IBM in the 1970 's and is now the standard for relational database query languages. An SQL statement is an English based program language that you can use to add, manage, and Access databases.
Strings that are added in an SQL statement can use double quotes, but in an ASP you need to use single quotes for normal execution. It should be written as insert into books (Name,email) VALUES (' Kitty ', ' kitty@263.com ').
   19. Question: What is an ActiveX control? Where can I get these ActiveX controls?
A: Microsoft ActiveX controls are reusable software components developed by software vendors. In addition to the ASP's embedded objects, additional installed ActiveX controls can be used in ASP, which can save a lot of valuable development time, in fact, in the ASP also embedded a lot of ActiveX controls can be used.
With ActiveX controls, you can quickly add special features to Web applications and development tools. For example, use the AdRotator object to make the advertisement scroll board, use the FileSystemObject object for file access, and use the marquee object to implement scrolling text.
There are now more than 1000 commercially available ActiveX controls that can be developed using a variety of programming languages such as c,c++, as well as Microsoft Visual Java Development Environment, Microsoft visible J + +. Once the ActiveX control has been developed, the design and developers can use it as a preinstalled component for developing client programs. Using ActiveX controls in this way eliminates the need for consumers to know how these components are developed and, in many cases, do not even have to program themselves to complete the design of a Web page or application.
There are more than 1000 commercial controls currently provided by third party software developers. The Microsoft ActiveX component Library (ActiveX Component Gallery) has information and associated connections that point to a variety of 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 Use strstartport= (Request.Form ("catmenu_0") statement to take the value of the starting site in the form is not found in the database?
A: This is because the value of the starting site you are taking may have spaces, for example, the original intention is "Hangzhou", but because the space exists, the ASP program to take the value may be "Hangzhou", and the database only "Hangzhou" record, of course, can not find, the solution is to use the TRIM function will be the two spaces of the string to remove all, The corresponding statement is:
Strstartport=trim (Request.Form ("Catmenu_0"))
   21, the problem: in the ASP when the life cycle of the variable, there are several ways to retain variable content?
A: Any action that causes the end of a Web page, such as pressing the "Refresh" button on the browser, or closing the browser, and then reopening it, will result in the end of the variable life cycle.
If you want to keep the contents of a variable at the end of a Web page for the next execution, you can use the Application object to implement it. For example, you can use the Application object to make statistics web site traffic counters.
The session object, like the Application object, stores the contents of the variable at the end of the Web page, but unlike the Application object, each online is a separate sessions object. Simply put, all online Internet users share only one application object, but each online surfer has its own session object.
The Application object and the session object can help us record the information on the server side, while the cookie object will record the information on the client with the help of the cookies provided by the browser. It is important to note that cookies are recorded in the browser information, so the data access is not as easy as accessing other ASP objects (information stored on the server side) so simple, in practice, only when the browser started browsing a server's Web page, The browser is able to exchange cookies data with the server before the server has downloaded any data to the browser.
   22. Question: What should be done after the object is used?
A: When you finish using the object, you first use the Close method to release the system resources occupied by the object, and then set the object value of "Nothing" to free up the memory occupied by the object, otherwise the Web Service site will run inefficient or even crash because of too many objects, as follows:
  
23. Question: Are there 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 behind it, and the syntax structure that is often used is as follows:
  
The method can accept methods of getting or post two transmissions, where the post is a method that allows large amounts of data to be transmitted, and the Get method will attach the data to be transferred behind the URL and then serve the server together, thus limiting the amount of data transferred. But the execution efficiency is better than the Post method.
You can use the Get or POST method to send data to the server, and the corresponding method for 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 to improve the efficiency of using the request collection?
A: When using the Request collection, it is much slower than accessing a local variable because it contains a series of searches for the related collection. Therefore, if you intend to use a value in the request collection more than once in a page, you should consider storing it as a local variable.
   25. Question: Can you use VBScript in ASP pages, or use JScript to mix script engines?
A: Although you can use VBScript in ASP pages, you can also use JScript. However, it is not advisable to use both JScript and VBScript on the same page. Because the server must instantiate and attempt to cache two (rather than one) scripting engines, this increases the system burden to some extent. Therefore, for performance reasons, you should not mix multiple scripting engines on the same page.

   26. Question: When we set up an ASP file, and the syntax, enter the following address through the browser, or open browsing through the Explorer: c:\inetpub\wwwroot\ A.asp, you will be unable to run the error, and prompted the right or the file is inaccessible, why not run the ASP file properly?
A: This is because the ASP file first requires the site to have the "execute (script)" attribute, and then requires the URL format to enter the address, rather than the DOS format, we need to install and start the Web service platform on the computer, and ensure that the ASP files are stored in the Web server virtual directory, You can browse through HTTP format, enter in the address bar of the browser: "http://Web site name (or site's IP address)/asp file name", after carriage return can see the server executes ASP file result in the browser.
   27. Question: What is asp.net? What does it have to do with ASP?
A: Active Server Pages (ASP, Active Server Page) is a relatively simple programming environment in which you can mix HTML, scripting languages, and a small number of components to create server-side Internet applications;
Asp. NET is a powerful programming environment that Microsoft can use to create web-based applications using a variety of high-level languages such as C # and scripting languages, HTML, XML, XSL, and so on. Asp. NET 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.net development, and Microsoft will develop C # as a strong competitor to Java. This is also Microsoft. An important part of the NET Framework. I think C # is the main tool for Microsoft to beat its opponents in the programming language field.
Asp. NET in object-oriented, database connection, large site applications are better than the ASP program, ASP. NET also offers new features such as built-in object caching and page-result caching, built-in XML support, simple processing of XML datasets, and more fully interactive server control.
Asp. NET is still completely locked in Microsoft's operating system, to really play asp.net potential, you have to use C # or vb.net. Both languages will become the core scripting language of the ASP.net standard.
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.