asp杂

下标

 

SELECT *
FROM Goods
WHERE (Range = '') AND ([Year] = '2004') AND (Goods_name <> '皮料')

'删除字段
ALTER TABLE cc DROP COLUMN bb

'删除表的所有数据,ID自动编号复位
truncate table company_info

'删除表
Drop table tablename

'ONCLICK
οnclick="javascript:window.location.href='Products.asp?id=1'"
οnclick="javascript:window.location.replace('Products.asp?id=1')"
οnclick="javascript:window.open('Products.asp','mytitle','width=200,height=60,scrollbars=no')"


'打开记录

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

conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("/datebase.mdb")

connstr ="Provider=SQLOLEDB.1;Password=capslockshift;Persist Security Info=True;User ID=sa;Initial Catalog=chinatvshopping;Data Source=server;Connect Timeout=15"

conn.open connstr

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

Set RS = conn.execute("select * from table")

RS.Open "SELECT * FROM Mytable",Conn,1

RS.Close

Conn.Close

set rs=conn.execute ("SELECT id,title FROM dbo.news WHERE (category = 1710)")

1.窗口置顶
在body加入
οnblur="window.focus()"
可使窗口置顶

1.1
showModalDialog("Company_Manage_query.asp",s,"dialogWidth:300px;status:no;dialogHeight:425px");

3.弹出窗口,并返回指定路径
<Script language='JavaScript'>window.alert('退出登陆');location.replace('company.asp');</Script>

<Script language='JavaScript'>window.alert('退出登陆');javascript:history.back(1);</Script>

3.弹出窗口,并返回原进入路径
<Script language='JavaScript'>window.alert('退出登陆');location.replace('"&request.ServerVariables("HTTP_REFERER")&"');</Script>

4.弹出窗口,并关闭此窗口
<Script language='JavaScript'>window.alert('多谢合作!');window.close();</Script>

5.防止重提交
<script language="JavaScript" type="text/JavaScript">
function add_onsubmit() {
 if (document.all||document.getElementById){
 //防止重复提交
 for (i=0;i<add.length;i++){
 var tempobj=add.elements[i]
 if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
 tempobj.disabled=true
 }
 }
 document.add.Submit.value="Waitting......"
 add.submit();
}
</script>


5.你确定要执行吗
<script language="JavaScript" type="text/JavaScript">
function SureDo
{
    if ( confirm("警告!您是否确定要?"))
        {
            formLIST.submit();
        }
}
</SCRIPT>

6.刷新主窗口...注:由OPEN打开的页面
window.opener.location.reload()

7.网页跳转(时间控制)
<meta http-equiv=refresh content="10; url=default.asp">

'多联接
SELECT a.name,b.password FROM admin a Left Outer JOIN manager b on a.id=b.id


'添加语句
insert into table (name,password) values ("huang","abcdefg")


'修改语句
UPDATE table SET name="huang" , password="abcdefg"


'删除语句
delete from table where ID in (10,11,12)


'超级添加哈哈哈
field1=array("Enterprise_name","Detailed_Address","Contatct_person","Headship","Main_Products","Enterprise_Intro","input_code","Main_ID")

value1=array(E_Enterprise_name,E_Detailed_Address,E_Contatct_person,E_Headship,E_Main_Products,E_Enterprise_Intro,UserInfo(2),new_id)

for i=0 to ubound(field1)
value1(i)=replace(value1(i),"'","''")
next

sql = "INSERT INTO E_COMPANY_INFO (" & Join(field1, ",") & ") VALUES ('" & Join(value1, "','") & "')"

'批处理添加数据
INSERT INTO test1 SELECT Username,Password FROM test WHERE Username = '4'

'拆分
Goto_ID=split(Goto_ID,",")

for i=0 to ubound(Goto_ID)
 Goto_ID(i)=replace(Goto_ID(i),"'","''")
next


'禁止缓存
Response.CacheControl = "no-cache"
Response.Buffer=false
Response.Expires=-1

''''''''''''''''''''''''
'
' 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 …) values (值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 "<P><center>对不起,数据库中没有相关信息!</center></P>"
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 "<CENTER>"
position=RS.PageSize*PageNo
pagebegin=position-RS.PageSize+1
if position <RS.RecordCount then
pagend=position
else
pagend= RS.RecordCount
end if
Response.Write "<P><font color='Navy'><B>数据库查询结果:</B>"
Response.Write "(共有"&RS.RecordCount &"条符合条件的信息,显示"&pagebegin&"-"&pagend&")</font></p>"
Response.Write "<TABLE WIDTH=600 BORDER=1 CELLPADDING=4 CELLSPACING=0 BGCOLOR=#FFFFFF>"
Response.Write "<TR BGCOLOR=#5FB5E2><FONT SIZE=2><TD><B>主题</B></TD><TD><B>用户</B></TD><TD><B>Email</B></TD><TD><B>发布日期</B></TD></FONT><TR BGCOLOR=#FFFFFF>"
Do while not (RS is nothing)
RowCount = RS.PageSize
Do While Not RS.EOF and rowcount > 0
If n=1 then
Response.Write "<TR BGCOLOR=#FFFFFF>"
ELSE
Response.Write "<TR BGCOLOR=#EEEEEE>"
End If
n=1-n %>
<TD><span style="font-size:9pt"><A href='view.asp?key=<% =RS("ID")%>'><% =RS("subject")%></A></span></td>
<TD><span style="font-size:9pt"><% =RS("name")%></A></span></td>
<TD><span style="font-size:9pt"><a href="mailto:<% =RS("email")%>"><% =RS("email")%></a></span> </TD>
<TD><span style="font-size:9pt"><% =RS("postdate")%></span> </td>
</TR>
<%
RowCount = RowCount - 1
RS.MoveNext
Loop
set RS = RS.NextRecordSet
Loop
Conn.Close
set rs = nothing
set Conn = nothing
%>
</TABLE>
<FORM METHOD=GET ACTION="list.asp">
<INPUT TYPE="HIDDEN" NAME="pageno" value="<% =PageNo %>">
<%
if PageNo > 1 Then
response.write "<INPUT TYPE=SUBMIT NAME='ScrollAction' value=' 上一页 '>"
end if
if RowCount = 0 and PageNo <>Total then
response.write "<INPUT TYPE=SUBMIT NAME='ScrollAction' value=' 下一页 '>"
end if
response.write "</FORM>"
End if
%>
<% End Sub %>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值