Recommended: asp FSO read and write files this file implementation code Asp has passed for a while, let me talk about using asp fso to implement file read and write operations. Friends who need to learn can refer to it. 1.AtEndOfStream This property indicates whether the end of the entire text file has been reached. Its value is TRUE or FALSE 2.CreateTextFile is used to create a new text file 3. Parameters saucer in OpenTextFile() method (See Greeting)
Common codes for ASP programming
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1. Connect ASP to Access database:
<%
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
%>
2. Connect ASP to SQL database:
<%
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:
set rs=server.createobject(adodb.recordset)
rs.open SQL statement,conn,3,2
3. Common SQL command usage methods:
(1) Data record filtering:
sql=select * from data table where field name=field value order by field name
sql=select * from data table where field name like '%field value %' order by field name
sql=select top 10 * from data table where field name order by field name
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:
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:
sql=delete from data table where conditional expression
sql=delete from data table (delete all records in the data table)
(4) Add data records:
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:
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:
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)
(6) Methods for recording set objects:
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
Determine that the data filled in is digital
if not isNumeric(request(field name)) then
response.write is not a number
else
response.write number
end if
Share: The difference between isNull, isEmpty and empty strings in asp In ASP, we often use two parameters, isNull and isEmpty, which are used when we judge that a certain string is empty. For example, if a string is str1, we often use if isNull(str1) or isEmpty(str1) then to judge, or use if str1=// then to judge whether the string is empty. Sometimes we are very confused, isNull, isEmpty and empty words