繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> ASP应用 >> ASP编程常用的代码

ASP编程常用的代码

2006-02-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:   sql中的保留字 action add aggregate all alter after and as asc avg avg_row_length auto_increment between bigint bit binary blob bool both by cascade case char character chang...
关键字:常用 编程 代码 ASP

  

sql中的保留字

action add aggregate all

alter after and as

asc avg avg_row_length auto_increment

between bigint bit binary

blob bool both by

cascade case char character

change check checksum column

columns comment constraint create

cross current_date current_time current_timestamp

data database databases date

datetime day day_hour day_minute

day_second dayofmonth dayofweek dayofyear

dec decimal default delayed

delay_key_write delete desc describe

distinct distinctrow double drop

end else escape escaped

enclosed enum explain exists

fields file first float

float4 float8 flush foreign

from for full function

global grant grants group

having heap high_priority hour

hour_minute hour_second hosts identified

ignore in index infile

inner insert insert_id int

integer interval int1 int2

int3 int4 int8 into

if is isam join

key keys kill last_insert_id

leading left length like

lines limit load local

lock logs long longblob

longtext low_priority max max_rows

match mediumblob mediumtext mediumint

middleint min_rows minute minute_second

modify month monthname myisam

natural numeric no not

null on optimize option

optionally or order outer

outfile pack_keys partial password

precision primary procedure process

processlist privileges read real

references reload regexp rename

replace restrict returns revoke

rlike row rows second

select set show shutdown

smallint soname sql_big_tables sql_big_selects

sql_low_priority_updates sql_log_off sql_log_update sql_select_limit

sql_small_result sql_big_result sql_warnings straight_join

starting status string table

tables temporary terminated text

then time timestamp tinyblob

tinytext tinyint trailing to

type use using unique

unlock unsigned update usage

values varchar variables varying

varbinary with write when

where year year_month zerofill

SQL常用命令使用方法:

(1) 数据记录筛选:

sql="select * from 数据表 where 字段名=字段值 order by 字段名 "

sql="select * from 数据表 where 字段名 like ‘%字段值%‘ order by 字段名 "

sql="select top 10 * from 数据表 where 字段名 order by 字段名 "

sql="select * from 数据表 where 字段名 in (‘值1‘,‘值2‘,‘值3‘)"

sql="select * from 数据表 where 字段名 between 值1 and 值2"

(2) 更新数据记录:

sql="update 数据表 set 字段名=字段值 where 条件表达式"

sql="update 数据表 set 字段1=值1,字段2=值2 …… 字段n=值n where 条件表达式"

(3) 删除数据记录:

sql="delete from 数据表 where 条件表达式"

sql="delete from 数据表" (将数据表所有记录删除)

(4) 添加数据记录:

sql="insert into 数据表 (字段1,字段2,字段3 …) valuess (值1,值2,值3 …)"

sql="insert into 目标数据表 select * from 源数据表" (把源数据表的记录添加到目标数据表)

(5) 数据记录统计函数:

AVG(字段名) 得出一个表格栏平均值

COUNT(*|字段名) 对数据行数的统计或对某一栏有值的数据行数统计

MAX(字段名) 取得一个表格栏最大的值

MIN(字段名) 取得一个表格栏最小的值

SUM(字段名) 把数据栏的值相加

引用以上函数的方法:

sql="select sum(字段名) as 别名 from 数据表 where 条件表达式"

set rs=conn.excute(sql)

用 rs("别名") 获取统的计值,其它函数运用同上。

(5) 数据表的建立和删除:

CREATE TABLE 数据表名称(字段1 类型1(长度),字段2 类型2(长度) …… )

例:CREATE TABLE tab01(name varchar(50),datetime default now())

DROP TABLE 数据表名称 (永久性删除一个数据表)

4. 记录集对象的方法:

rs.movenext 将记录指针从当前的位置向下移一行

rs.moveprevious 将记录指针从当前的位置向上移一行

rs.movefirst 将记录指针移到数据表第一行

rs.movelast 将记录指针移到数据表最后一行

rs.absoluteposition=N 将记录指针移到数据表第N行

rs.absolutepage=N 将记录指针移到第N页的第一行

rs.pagesize=N 设置每页为N条记录

rs.pagecount 根据 pagesize 的设置返回总页数

rs.recordcount 返回记录总数

rs.bof 返回记录指针是否超出数据表首端,true表示是,false为否

rs.eof 返回记录指针是否超出数据表末端,true表示是,false为否

rs.delete 删除当前记录,但记录指针不会向下移动

rs.addnew 添加记录到数据表末端

rs.update 更新数据表记录

判断所填数据是数字型

if not isNumeric(request("字段名称")) then

response.write "不是数字"

else

response.write "数字"

end if

 

--------------------------------------------------------------------------------

simpleli 于 2002-03-23 15:08:45 加贴在 ASP论坛 上

--------------------------------------------------------------------------------

内容(3469bytes):

這是論壇的分頁顯示﹐你改一下就行了。

<% Sub ShowList() %>

<%

PgSz=20 '设定开关,指定每一页所显示的貼子數,默认为20貼子一页

Set Conn = Server.CreateObject("ADODB.Connection")

Set RS = Server.CreateObject("ADODB.RecordSet")

sql = "SELECT * FROM message order by ID DESC"

'查询所有帖子,并按帖子的ID倒序排列

Conn.Open "bbs"

RS.open sql,Conn,1,1

If RS.RecordCount=0 then

response.write "

对不起,数据库中没有相关信息!

"

else

RS.PageSize = Cint(PgSz) '设定PageSize属性的值

Total=INT(RS.recordcount / PgSz * -1)*-1 '计算可显示页面的总数

PageNo=Request("pageno")

if PageNo="" Then

PageNo = 1

else

PageNo=PageNo+1

PageNo=PageNo-1

end if

ScrollAction = Request("ScrollAction")

if ScrollAction = " 上一页 " Then

PageNo=PageNo-1

end if

if ScrollAction = " 下一页 " Then

PageNo=PageNo+1

end if

if PageNo <1 Then

PageNo = 1

end if

n=1

RS.AbsolutePage = PageNo

Response.Write "

"

position=RS.PageSize*PageNo

pagebegin=position-RS.PageSize+1

if position

pagend=position

else

pagend= RS.RecordCount

end if

Response.Write "

数据库查询结果:"

Response.Write "(共有"&RS.RecordCount &"条符合条件的信息,显示"&pagebegin&"-"&pagend&")

"

Response.Write ""

Response.Write "

"

Do while not (RS is nothing)

RowCount = RS.PageSize

Do While Not RS.EOF and rowcount > 0

If n=1 then

Response.Write "

"

ELSE

Response.Write "

"

End If

n=1-n %>

<%

RowCount = RowCount - 1

RS.MoveNext

Loop

set RS = RS.NextRecordSet

Loop

Conn.Close

set rs = nothing

set Conn = nothing

%>

主题用户Email发布日期
<% =RS("subject")%> <% =RS("name")%> "><% =RS("email")%> <% =RS("postdate")%>

<%

if PageNo > 1 Then

response.write ""

end if

if RowCount = 0 and PageNo <>Total then

response.write ""

end if

response.write "

"

End if

%>

<% End Sub %>

责任编辑:admin
相关文章