几个Asp小片断。

Asp 遍历Session Application:
for each unit in Application.Contents
Response.Write unit
&"<br/>"
next
for each unit in session.Contents
Response.Write unit
&"<br/>"
next

 asp 遍历未知字段数表全部字段: 

if(request("conn")==""then
MM_conn_STRING 
= "driver={SQL Server};server=127.0.0.1; uid=sa;pwd=xnqc@rongw147*%@;database=master"
else
MM_conn_STRING 
=request("conn")
end if

public conn
set conn=server.CreateObject("ADODB.Connection")
conn.open MM_conn_STRING

if request("e")<>"" then
    conn.execute(request(
"sql"))
end if
if request("r")<>"" then
    
Set rsnews = Server.CreateObject("ADODB.Recordset")
    rsnews.ActiveConnection 
= MM_conn_STRING
    rsnews.Source 
= "SELECT * FROM qclt.dbo.link ORDER BY bh"
    rsnews.CursorType 
= 0
    rsnews.CursorLocation 
= 2
    rsnews.LockType 
= 1
    rsnews.Open()    
    
while not rsnews.eof
        
for i=0 to rs.Fields.Count-1
            response.Write rsnews.Fields(i).name
&":"&rsnews.Fields(i).value&"<br>"
        
next
        rsnews.movenext
    
wend
end if

asp 发送邮件 mail:

<
Dim StrHtml = "<html><head>"
StrHtml 
= StrHtml &"<Title>Greeting</Title></head>"
StrHtml 
= StrHtml &"<body>"
StrHtml 
= StrHtml &"<p>How are you</p>" 
StrHtml 
= StrHtml &"<img src="Sample.jpg">" 
StrHtml 
= StrHtml &"</body>" 

Set ObjSendMail=CreateObject("CDONTS.NewMail")

With ObjSendMail

.From 
= "me@domain.com"
.To 
= "receiver@domain.com"
' 設定傳送郵件格式為HTML 
.BodyFormat = CdoBodyFormatHtml 
' 設定超連結基底
.ContentBase = "http://ww.anywhere.com"
' 設定郵件內容中所有URL的絕對會相對位址 
.ContentLocation = "images/"
.Subject 
= "Give you a Picture"
.Body 
= StrHtml
.Send 

EndWith

'移除物件
Set ObjSendMail=Nothing
%
>

Asp 发送和接收数据:

var oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
oXMLHTTP.open(
"POST""xml_handler.asp"false);
oXMLHTTP.send(xml_to_send);
 
由于Request对象会实现IStream接口,所以你可以通过使用DOMDocument对象的load()方法来加载所要提交的XML:
 
Dim oDOM
Set oDOM = Server.CreateObject("MSXML2.DOMDocument")
oDOM.load Request

asp 利用adodbstream隐藏文件地址实现下载:

<%
function saveFile(recfilen)
    
set Astream=CreateObject("Adodb.Stream")'asp Server.CreateObject("Adodb.Stream")
    Astream.type=1
    Astream.Mode 
= 3'     adModeRead =1 
                    '  adModeReadWrite =3 
                    '  adModeRecursive =4194304 
                    '  adModeShareDenyNone =16 
                    '  adModeShareDenyRead =4 
                    '  adModeShareDenyWrite =8 
                    '  adModeShareExclusive =12 
                    '  adModeUnknown =0 
                    '  adModeWrite =2 
    
    Astream.open
    
'Astream.CharSet = "GB2312"
    Astream.LoadFromFile(recfilen) '装载文件
    Assp=Astream.size    
    Astream.Position 
=0 '装载文件时设置为Assp
    'Astream.Writetext tmpstr00,1
    saveFile=Astream.read(Assp)
end function
fn
="121.mp3"
data
=saveFile(server.mappath(fn))
Response.AddHeader 
"Content-Disposition""attachment; filename=" &fn
Response.AddHeader 
"Content-Length"len(data)
Response.ContentType 
= "application/octet-stream"
Response.BinaryWrite Data
%
>

 

posted @ 2006-10-27 10:18  MultiThread-PHP  阅读(177)  评论(0编辑  收藏  举报