ASP实例学习三
时间:2008-12-05 来源:hkebao
<div><!--#include file="lay.asp"--></div>
可以将一个文件包含到一个div中去!
<!--#include FILE="conn.asp" -->
<!-- #include file="admin/function.asp" -->
可以将连接数据库与公共的函数单元引入进来的哦!
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="802" height="193">
<param name="movie" value="img/top.swf">
<param name="quality" value="high">
<PARAM NAME="wmode" VALUE="transparent">
<embed src="img/top.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="802" height="193"></embed>
</object>
引入包含一个flash文件来的哦!
写一个关闭连接的函数吧!
function connclose()
'response.Write(isobject(conn))&vbcrlf
'response.Write(isnull(conn))&vbcrlf
'response.Write(VarType(conn))&vbcrlf
if VarType(conn)=8 then
conn.close
set conn=nothing
conn=""
end if
end function
[来研究一下varType]
会返回以下的结果哦:
vbEmpty 0 返回0表示空
vbNumll 1
vbInteger 2
vbLong 3
等等......
<%content=conn.execute("select [content] from [cont_int] where [id]=1")(0)%>
这样可以得到具体的一个变量的值的哦!
可以用JS来实现超链接的哦哈哈!
<form name="form1111" id="form1111">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)" >
<option selected>---友情链接---</option>
<%set rs=conn.execute("select title,url from [url] where typeid=1 order by [order1] desc")
do while not rs.eof
%>
<option value="<%=rs(1)%>"><%=rs(0)%></option>
<%
rs.movenext
loop
set rs=nothing
%>
</select>
</form>
ASP代码:
Set rs = conn.execute("select title,url from [url] where typeid=1")
do while not eof
//可以得到具体哪项的值rs(1)
rs.movenext
loop
set rs = nothing
相当于
do while
loop
[服务器端获取来自客户端的数据]
sname = formatstr(request.form("sname"))
[ASP处理Cookie的信息哦!]
response.Cookies("zxzx")="true"
一个名-值哦!
<%=content%>可以将数据库中的数据这样来展现出来的哦!
count1=RS.RecordCount:这个很像Delphi中的记录个数哦哈哈!
<%
Set rs = Server.createObject("ADODB.Recordset")
sql = "select id,titile from new"
rs.open conn,sql,1,3
count = rs.recordcount
if count = 0 then
response.write "the number is null"
else
end if
%>
//ASP真的比较简单的哦!
CLng 函数可返回表达式,此表达式已被转换为 Long 子类型的 Variant
VBScript中的内置函数哦!
可以将一个文件包含到一个div中去!
<!--#include FILE="conn.asp" -->
<!-- #include file="admin/function.asp" -->
可以将连接数据库与公共的函数单元引入进来的哦!
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="802" height="193">
<param name="movie" value="img/top.swf">
<param name="quality" value="high">
<PARAM NAME="wmode" VALUE="transparent">
<embed src="img/top.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="802" height="193"></embed>
</object>
引入包含一个flash文件来的哦!
写一个关闭连接的函数吧!
function connclose()
'response.Write(isobject(conn))&vbcrlf
'response.Write(isnull(conn))&vbcrlf
'response.Write(VarType(conn))&vbcrlf
if VarType(conn)=8 then
conn.close
set conn=nothing
conn=""
end if
end function
[来研究一下varType]
会返回以下的结果哦:
vbEmpty 0 返回0表示空
vbNumll 1
vbInteger 2
vbLong 3
等等......
<%content=conn.execute("select [content] from [cont_int] where [id]=1")(0)%>
这样可以得到具体的一个变量的值的哦!
可以用JS来实现超链接的哦哈哈!
<form name="form1111" id="form1111">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)" >
<option selected>---友情链接---</option>
<%set rs=conn.execute("select title,url from [url] where typeid=1 order by [order1] desc")
do while not rs.eof
%>
<option value="<%=rs(1)%>"><%=rs(0)%></option>
<%
rs.movenext
loop
set rs=nothing
%>
</select>
</form>
ASP代码:
Set rs = conn.execute("select title,url from [url] where typeid=1")
do while not eof
//可以得到具体哪项的值rs(1)
rs.movenext
loop
set rs = nothing
相当于
do while
loop
[服务器端获取来自客户端的数据]
sname = formatstr(request.form("sname"))
[ASP处理Cookie的信息哦!]
response.Cookies("zxzx")="true"
一个名-值哦!
<%=content%>可以将数据库中的数据这样来展现出来的哦!
count1=RS.RecordCount:这个很像Delphi中的记录个数哦哈哈!
<%
Set rs = Server.createObject("ADODB.Recordset")
sql = "select id,titile from new"
rs.open conn,sql,1,3
count = rs.recordcount
if count = 0 then
response.write "the number is null"
else
end if
%>
//ASP真的比较简单的哦!
CLng 函数可返回表达式,此表达式已被转换为 Long 子类型的 Variant
VBScript中的内置函数哦!
dim a,b
a=23524.45
b=23525.55
document.write(CLng(a) & "<br />")
document.write(CLng(b))
可以输出:23524
23526
[看看如何进行更新一个数据表吧!]
Set Rs=Server.CreateObject("Adodb.Recordset")
sql="update t set t.a = "" where t.id = """
conn.execute(sql)
rs.close
set rs=nothing
直接执行一个SQL命令就可以了哦哈哈!
<a href="news_view.asp?id=<%=rs(0)%>" target="_blank"><%=rs(1)%></a>
可以将一个ID传递到这个ASP中去。然后处理这个ASP页面哈哈!
如果有一个超链接
<a href = "a.asp?id=123">dd</a>
那在a.asp中可以这样来接受参数值的哦哈哈!
request("id")
在JSP中是这样来写的哦:request.getParatemers("id")
注意区别啊。
conn.execute("update [new] set djcount=djcount+1 where id="&r_id)
可以这样来更新一个SQL命令的哦!
set rs=conn.execute("SELECT Id,Title,author,Content,Addtime,djcount,typeid FROM [new] where id="&r_id)
查询也可以这样处理的哦:
rs.open conn,sql,1,3
也可以将其当作 一个SQL命令来进行处理的哦!
[以后统一用这个语句吧!]
set rs = conn.execute("select * from t")
conn.execute("update t set ")
与JSP差不多的哦!
都是可以通过execute动作来执行的哦!
查询出来之后可以这样来得到字段相对应的值的哦!
title=rs("title")
set rs=conn.execute("SELECT Id,Title,author,Content,Addtime,djcount,typeid FROM [new] where id="&r_id)
if rs.eof then
call pop_msgend("无此信息,可能已被删除")
else
title=rs("title")
author=rs("author")
djcount=rs("djcount")
content=rs("content")
addtime=rs("addtime")
typeid=rs("typeid")
end if
set rs=nothing
相关阅读 更多 +