1. How to use ASP to judge your website's virtual physical path: Using mappath method
the physical path to this Virtual Website IS : b> font> <% = server.mappath ("/")%> font> p> 2 How do I know the browser used by the user? A: a method using the Request object strBrowser = Request.ServerVariables ( "HTTP_USER_AGENT") If Instr (strBrowser, "MSIE") <> 0 Then Response.redirect ( "ForMSIEOnly.htm") Else Response.redirect ( "ForAll.htm" ) End IF
3. How to calculate the average number of repetitions per day Answer: Solution <% StartDate = Datediff ("D", NOW, "01/01/1990") if strdate <0 dam stdate = startdate * -1 avgvpd = int 4 Usercnt) / startdate)%> Display result <% response.write (avgvpd)%> That Is it.this page has been viewed Since November 10,1998
4. How to display a random image <% DIM P, PPIC, DPIC PPIC = 12 Randomize P = INT (PPIC * RND) 1) DPIC = "Graphix / Randompics /" & P & ". GIF"%> Show
5. How to return to the previous page answer: >"> preivous page a> or with images: ">>
6. How to determine the other party's IP address answer: <% = Request.serverVariables ("remote_addr)%>
7. How to link to a pair of pictures: <% @ languages = VBS cript%> <% response.expires = 0 strimagename = "graphix / errors / errooriamge.gif" response.redirect (strimagename)%>
8. Forced input password dialog box: Put this sentence to the beginning of the page <% response.status = "401 Not Authorized" response.end%> 9. How to transfer variables from one page to another: Hidden Type to transmit variable <% form method = "post" action = "mynextpage.asp"> <% for each item in request.form%> <% s cript language = '' javas cript ''> Alert ("<% = Yourvar%> ") s cripe>
11. Is there a way to protect your source code, do not give people an answer: You can download a Microsoft's Windows S Cript Encoder, which can encrypt the ASP script and client JavaS CRIPT / VBS CRIPT script. . . However, after the client encrypts, only IE5 can execute, after the server-side script is encrypted, only the S Cript Engine 5 installed on the server can be executed.
12. How can I send Query String from an ASP file to another? A: The former file adds the following sentence: response.redirect ("second.asp?" & Required.servervariables ("query_string"))
13.Global.asa files don't always work? A: Only the web directory is set to Web Application, Global.asa is only valid, and Global.asa is valid in the root of a Web Application. IIS4 can use Internet Service Manager to set Application Setting how to make the HTM file like an ASP file can execute script code?
14. How can I make the script code as the HTM file like an ASP file? Answer: Internet sevices manager -> Select Default Web Site -> Right Mark -> Menu Properties -> Home -> Application Setting -> Click button "Configuration" -> App Mapping -> Click button "Add "-> EXECUTABLE BROWSE Selection / Winnt/System32/INetsrv/asp.dll Extension Enter HTM Method Exclusions Enter Put.delete All OK. But it is worth noting that this is also processed by ASP.DLL for HTM, and the efficiency will be reduced. 15. How to register the component A: There are two ways. The first method: Hand-registered DLL This method is used from IIS 3.0 to IIS 4.0 and other web server. It requires you to execute in the command line mode, enter the directory containing the DLL, and enter: regsvr32 component_name.dll, for example C: / temp / regsvr32 aspemail.dll, will register DLL's specific information in the registry in the registry in the server . This component can then be used on the server, but this method has a defect. When the component is registered with this method, the component must have the corresponding setting NT anonymous account with permission to execute this DLL. In particular, some components need to read the registry, so the method of this registration component is only used in the case where there is no MTS on the server. Use: regsvr32 / u aspobject.dll Example C: / Temp / Regsvr32 / u Aneiodbc.dll
The second method: Using the MTS (Microsoft Transaction Server) MTS is an added feature of IIS 4, but it provides huge improvements. MTS allows you to specify that only privileged users can access components and greatly improve the security settings on the website server. The steps to register the components on the MTS are as follows: 1) Open the IIS Management Console. 2) Expand Transaction Server, right-click "PKGS Installed" and select "New Package". 3) Click Create An Empty Package. 4) Naming the package. 5) Specify the Administrator account or use "Interactive" (if the server is often used using administrator). 6) Now use Right-click "Components" after the package you just created. Select "New Ten Component". 7) Select "Install New Component" [B]. 8) Locate your .dll file and select Next to complete. To delete this object, just select its icon, then select Delete. Note: Pay special attention to the second method, it is used to debug the best way to write components, without having to restart the machine each time.
16. ASP and Access database connection:
<% @Language = VBS CRIPT%> <% DIM CONN, MDBFILE MDBFILE = Server.mAppath ("Database Name. MDB") set conn = server.createObject ("adodb.connection" conn.open "driver = {Microsoft Access DRIVER (* .mdb)}; uid = admin; pwd = database password; dbq = "& mdbfile%>
17. ASP is connected to the SQL database:
<% @Language = VBS cript%> <% DIM conn set conn = server.createObject ("adoDb.connection") Con -.open "provider = SQLOLDB; DATA source = SQL server name or IP address; UID = SA; PWD = Database password; database = database name%>
Establish record set objects:
SET RS = Server.createObject ("AdoDb.Recordset") RS.Open SQL statement, CONN, 3, 2
18. SQL common command usage:
(1) Data Record Screening:
SQL = "SELECT * FROM data table where field name = field value ORDER BY field name [DESC]"
SQL = "SELECT * FROM DATA WHERE Field Name Like '' '% Field Value%' 'ORDER BY Field Name [DESC]
SQL = "SELECT TOP 10 * FROM DATA WHERE Field Name ORDER BY Field Name [DESC]"
SQL = "SELECT * FROM data table where field name in ('' value 1 ',' 'value 2', '' value 3 '')"
SQL = "SELECT * FROM DATA WHERE Field Name BetWeen Value 1 AND Value 2"
(2) Update data record:
SQL = "Update Datasheet Set Field Name = Field Value WHERE Condition Expression"
SQL = "Update Data Table Set Field 1 = Value 1, Field 2 = Value 2 ... Field N = Value N Where Conditions Expression"
(3) Delete data records:
SQL = "Delete from Data Sheet WHERE Condition Expression"
SQL = "delete from data table" (deleted all records of data tables)
(4) Add a data record:
SQL = "INSERT INTO Data Sheet (Field 1, Field 2, Field 3 ...) Valuess (value 1, value 2, value 3 ...)"
SQL = "INSERT INTO Target Data Table Select * From Source Data Sheet" (Add record of the source data table to the target data sheet)
(5) Data logging statistics:
AVG (Field Name) gives a table bar average count (* | field name) Statistics on the number of data lines or the maximum value of the value of the value of a value for a column. MIN (Field Name) gets the smallest value of a table bar SUM (field name) adds the value of the data bar.
Citing the above function:
SQL = "SELECT SUM (field name) AS alias from Datasheet Where WHERE Condition Expression" SET RS = Conn.excute (SQL) The value of the value is obtained by RS ("alias", and other functions are using the same.
(5) Establishment and deletion of data sheets:
Create Table Data Sheet Name (Field 1 Type 1 (Length), Field 2 Type 2 (Length) ...)
Example: Create Table Tab01 (Name Varchar (50), DateTime Default now ())
DROP TABLE Datasheet Name (permanently delete a data sheet)