Recommended: A brief discussion on the ideas and error correction of ASP programming For beginners who use ASP technology to program, it is their first feeling that they have no idea how to start. The author once had such an experience. After some hardships, you will find inspiration. Now I will devote some of the experience I have accumulated in programming to readers. 1
11. Is there a way to protect your source code so that you can’t see it?
Answer: You can download a Microsoft Windows Script Encoder, which can encrypt the asp script and client javascript/vbscript script. However, after the client is encrypted, only ie5 can be executed. After the server-side script is encrypted, only script engine 5 is installed on the server (installing one ie5 can be found).
12. How can I transfer query string from one asp file to another?
Answer: The former file adds the next sentence: Response.Redirect(second.asp? & Request.ServerVariables(QUERY_STRING))
13. The global.asa file always doesn't work?
Answer: Only when the web directory is set to web application, global.asa is valid, and global.asa is valid in the root directory of a web application. IIS4 can use Internet Service Manager to set application settings How can the htm file execute script code like an asp file?
14. How can the htm file be able to execute script code like an asp file?
Answer: Internet Services Manager -> Select default web site -> Right mouse button -> Menu properties -> Home directory -> Application Settings -> Click button configuration -> App mapping -> Click button Add -> executable browser Select /WINNT/SYSTEM32/INETSRV/ASP.DLL EXTENSION Enter htm method excclusions Enter PUT.DELETE All confirm. However, it is worth noting that in this way, the efficiency will be reduced.
15. How to register components
Answer: There are two ways.
The first method: manually register DLL This method is used from IIs 3.0 to IIs 4.0 and other Web Servers. It requires you to execute it in the command line, enter the directory containing the DLL, and enter: regsvr32 component_name.dll For example, c:/temp/regsvr32 AspEmail.dll It will register the specific information of the dll into the registry in the server. Then this component can be used on the server, but this method has a flaw. After registering a component using this method, the component must set the corresponding anonymous account with NT to have permission to execute this dll. In particular, some components need to read the registry, so the method of registering components is just to use if there is no MTS on the server. To unregister this dll, use: regsvr32 /u aspobject.dll example c:/temp/regsvr32 /u aneiodbc.dll
The second method: Using MTS (Microsoft Transaction Server) MTS is a new feature of IIS 4, but it provides a huge improvement. MTS allows you to specify that only privileged users can access components, greatly improving security settings on the website server. The steps to register a component on 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) Name the package.
5) Specify the administrator account or use interactive (if the server often logs in with administrator).
6) Now use right-click the expanded components below the package you just created. Select new then component.
7) Select install new component.
Find your .dll file and select next to finish.
To delete this object, just select its icon and select delete.
Note: Pay special attention to the second method, which is the best way to debug the components you write yourself without having to restart the machine every time.
16. Connect ASP to Access database:
| The following is the quoted content: <%@ language=VBscript%> <% 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. Connect ASP to SQL database:
| The following is the quoted content: <%@ language=VBscript%> <% dim conn set conn=server.createobject(ADODB.connection) con.open PROVIDER=SQLOLEDB;DATA SOURCE=SQL server name or IP address;UID=sa;PWD=database password;DATABASE=database name %> |
Create a record set object:
| The following is the quoted content: <% set rs=server.createobject(adodb.recordset) rs.open SQL statement,conn,3,2 %> |
18. Common SQL command usage methods:
(1) Data record filtering:
| The following is the quoted content: sql=select * from data table where field name=field value order by field name[desc] sql=select * from data table where field name like '%field value %' order by field name [desc] sql=select top 10 * from data table 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 table where field name between value 1 and value 2 |
(2) Update data records:
| The following is the quoted content: sql=update data table set field name=field value where conditional expression sql=update data table set Field 1=value 1, Field 2=value 2... Field n=value n where conditional expression |
(3) Delete data records:
| The following is the quoted content: sql=delete from data table where conditional expression sql=delete from data table (delete all records in the data table) |
(4) Add data records:
| The following is the quoted content: sql=insert into data table (field 1, field 2, field 3…) valuess (value 1, value 2, value 3…) sql=insert into target data table select * from source data table (add the record of the source data table to the target data table) |
(5) Data record statistics function:
| The following is the quoted content: AVG (field name) to obtain an average value of a table column COUNT(*|field name) Statistics on the number of data rows or statistics on the number of data rows with values in a certain column MAX (field name) Get the maximum value of a table column MIN (field name) Get the minimum value of a table column SUM (field name) adds the value of the data column |
Reference the above function method:
| The following is the quoted content: sql=select sum(field name) as alias from data table where conditional expression set rs=conn.excute(sql) |
Use rs (alias) to get the statistics, and other functions are used the same as above.
(5) Establishment and deletion of data tables:
CREATE TABLE Data table name (field 1 type 1 (length), field 2 type 2 (length)…)
Example: CREATE TABLE tab01(name varchar(50), datetime default now())
DROP TABLE Data table name (permanently delete a data table)
19. Methods for recording set objects:
| The following is the quoted content: rs.movenext Moves the record pointer down one line from the current position rs.moveprevious Moves the record pointer up one line from the current position rs.movefirst Moves the record pointer to the first row of the data table rs.movelast Moves the record pointer to the last row of the data table rs.absoluteposition=N Move the record pointer to row N of the data table rs.absolutepage=N Move the record pointer to the first line of page N rs.pagesize=N Set each page to N records rs.pagecount returns the total number of pages according to the settings of pagesize rs.recordcount Returns the total number of records rs.bof Returns whether the record pointer exceeds the head of the data table. True means yes, false is no rs.eof Returns whether the record pointer exceeds the end of the data table, true means yes, false is no rs.delete deletes the current record, but the record pointer does not move downwards rs.addnew Add record to the end of the data table rs.update Update data table records |
20. Recordset object method
Open method
| The following is the quoted content: recordset.Open Source,ActiveConnection,CursorType,LockType,Options Source The Recordset object can be connected to the Command object through the Source property. The Source parameter can be a Command object name, a SQL command, a specified data table name, or a Stored Procedure. If this parameter is omitted, the system uses the Source property of the Recordset object. |
Share: ASP 3.0 Advanced Programming (39) 8.4.3 It is very easy to create a record set. It is implemented by calling the Open method of the Recordset object: Recordset.Open [Source], [ActiveConnection], [CursorType], [LockType], [Options] The parameters and descriptions are as shown in Table 8-