1. How to use GetRows:
<%
Setconn=Server.CreateObject("Adodb.Connection")
conn.Open"Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.Mappath("test.mdb")
SetRs=Server.CreateObject("Adodb.Recordset")
Rs.Open"SelectTop2*From table name",conn,0,1
DimArray_str
Array_str=rs.GetRows()
Response.Write"First record:<br>"
Response.WriteArray_str(0,0)&"<br>"
Response.WriteArray_str(1,0)&"<br>"
Response.WriteArray_str(2,0)&"<br>"
Response.WriteArray_str(3,0)&"<br>"
Response.Write"Second record:<br>"
Response.WriteArray_str(0,1)&"<br>"
Response.WriteArray_str(1,1)&"<br>"
Response.WriteArray_str(2,1)&"<br>"
Response.WriteArray_str(3,1)&"<br>"
%>
If you are familiar with GetRows, you will find that operating databases are simpler and more optimized. There are many advantages:)
2. Is it necessary to declare variables?
The variable needs to be declared in the following situations:
1. You are a good programmer
2. Write high-quality code
Add the following code to force the declaration of variables:
<%OptionExplicit%>
3. How to call server-side functions on the client?
Remote scripting technology (RemoteScripting) is characterized by the fact that the client script does not need to refresh the entire page when calling the server script.
Generally speaking, when a web page needs to interact with the server, the form data must be submitted and the entire page must be refreshed. Using remote script calling technology, client scripts can call remote script functions like local functions, especially in complex form verification and frequent database operations, which is fully utilized.
Its basic principle is that with the help of a set of interface functions provided by itself, the client program can call server-side code through a proxy process (a javaapplet). JavaApplet (RSProxy.class) works in the background. Usually, the user code does not need to operate it directly, and its configuration is also automatically completed. Remote script calls can be either a synchronous call ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ A basic remote script calling technique must include the following files:
RS.htm: Includes client support code
RSProxy.class: This is a JavaApplet that actually completes the client/server interaction process
RS.asp: Server-side support code
When using the remote script to call the function, both the client and server-side code must meet certain requirements: on the server side, the remote script call must be enabled: use #include to include RS.asp and call the RSDispath function. The key to implementing remote script support on the server side is to create a public_description object. It is different from the normal ASP page execution process when it is called remotely. It puts global script code into a function and calls it explicitly.