An ASP learning notes (Serial II)

Source: Internet
Author: User
Tags date array exit count connect sql variable trim
Note 1. Set background color in script: document.bgcolor= "Red"
Window positioning and resizing in 2.JavaScript scripts:
function Win () {
if (Window.screen) {
Window.moveto (0, 0);
Window.resizeto (800, 600);
}
}
3.VBS in exit for immediately exit the loop, the subsequent content will not be executed. So need to pay attention to finish the treatment before this.
4. If you do not explicitly declare a variable, you may inadvertently change the value of a global variable.
<%
Y = 1
Call Setlocalvariable
Response.Write Y
Sub setlocalvariable ()
Y = 2
End Sub
%>
This script command returns 2 because the variable is not explicitly declared. The procedure call sets Y to 2 o'clock, which the script engine considers to be modifying the global variable:

The ideal variable usage scenario is shown in the following example:
<%dim Y = 1
Call Setlocalvariable
Response.Write Y
Sub setlocalvariable ()
Dim Y
Y = 2
End Sub%>
This script command eventually outputs a Y-value of 1 because it explicitly defines two variables named Y.
This kind of slight difference may be no harm, but when the system is large to a certain extent, we must pay attention to, because there may be a lot of inexplicable problems!!
  
5. Learn to define and use constants.
6. Here, the DateSerial function returns the date of 20 years (1990-20) 2 months (11-2) and one day (10-1) prior to November 10, 1998: That is, September 9, 1978. The procedure is as follows: Datep=dateserial (1998-20, 11-2,10-1)
7. Itemp=dateserial (date), month (date), day (date)-7)
Itemp=datevalue (ITEMP)
Sql= "Select * from Message Where message.creatime
Between # "&date&" #
and # "&itemp&" # "

Here we come to a set of function Year,month,day, which are used to get the year, month, and day of a date. Date is a constant that represents today's date, and function DateValue is a variable that converts a string variable into a date format. In the third line of this procedure, we first contacted the standard SQL query statement, what does this sentence mean?

"Select" is a standard SQL database query command, in which we can retrieve data from the database and provide the results to the user, where "*" means to query all records in the database named "Message", and "where" The function is to set a query condition to take out the qualifying records in the database, "Message.creatime" is a variable that stores the date the record was created in the database. The whole sentence is understood by querying all the records in the database named message, and storing all the records in the variable SQL that were created in today and 7th before today.
9. If {statement} elseif {statement} elseif {...} else {statement} End if (remember line wrap)
10.if {Statement} else {statement} can have this streamlined format for relatively short statements
11. Connect SQL Server in OLE mode:
Conn_ole.asp
<%
Set Conn = Server.CreateObject ("ADODB. Connection ")
Conn.Open "Provider=sqloledb;data source=10.1.43.238,2433; Uid=course_user; Pwd=course_password;database=course "
%>
12. I can not remember why I wrote down this procedure, COURSE_DSN should mean DSN bar.
<%
Set conn=server.createobject ("ADODB. Connection ")" Create an object to connect to a database
Conn. Open "Course_dsn", "Course_user", "Course_password" Use this object to connect to the database
Conn.execute "Delete from User_info"
%>
Result: All data in the User_info table is deleted
13. True Cache-Free implementation:
Response.buffer=true
Response.cachecontrol= "No-chache"
Response.expiresabsolute=now ()-1
Response.expires=0
14. One way to read server-side data to a variable in the client:
var Onecount;
onecount=0;
subcat = new Array ();
<%
Count = 0
Do as not rs.eof
%>
SUBCAT[&LT;%=COUNT%&GT] = new Array ("<%= Trim (rs (" Nsort_name "))%>", "<%= Trim (rs (" sort_id "))%>", "<%= Trim (RS ("nsort_id"))%> ");
<%
Count = Count + 1
Rs.movenext
Loop
Rs.close
%>
onecount=<%=count%>;


---to be continued



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.