孕妇烂脚丫和痒怎么办:ASP技巧集锦2
来源:百度文库 编辑:中财网 时间:2024/04/27 17:15:14
调用Css做颜色变换:
======================
调用Css做颜色变换:
======================
ASP中怎么运行一个服务器端程序呢
Set WShShell = Server.CreateObject("WScript.Shell")
RetCode = WShShell.Run("d:\xxx.exe", 1, True)
‘功能: 过虑HTML字符
‘输入:字符串
‘输出:经格式化后的字符串
function HTMLEncode(fString)
if not isnull(fString) then
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
fString = Replace(fString, CHR(32)&CHR(32), " ")
fString = Replace(fString, CHR(9), " ")
fString = Replace(fString, CHR(34), """)
fString = Replace(fString, CHR(39), "'")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "
")
fString = Replace(fString, CHR(10), "
")
HTMLEncode = fString
end if
end function
‘参数:系统(如:product,article),条件(如果是数值,则默认为categoryID的值),排序,
‘每页显示记录数,模式(more:显示更多字样,page:显示翻页导航),
‘翻页导航模式(number:显示数字,page:显示上一页,下一页),记录显示模版名(显示记录的过程名)
class List
dim p_system ‘系统表,如tblProduct,tblArticle
dim p_where ‘条件
dim p_orderBy ‘排序
dim p_recordCount ‘每页显示记录数
dim p_horizontal ‘每行显示记录数
dim p_mode ‘列表模式,参数:more(更多模式,显示更多字样),page(列表模式,显示翻页导航)
dim p_moreURL ‘更多模式时的URL
dim p_paginationMode ‘翻页导航模式,参数:number(数字导航,显示如:1,2,3,4),page(翻页导航,显示如:上一页,下一页)
dim p_models ‘列表模版过程
dim p_table ‘列表的table标签
dim p_page ‘页码
dim p_member ‘是否显示会员产品
dim p_groupWhere
Private Sub Class_Initialize
p_system=""
p_where=""
p_orderBy=" order by categoryID,orderBy,postdate"
p_recordCount=15
p_horizontal=4
p_mode=""
p_moreURL=""
p_paginationMode="page"
p_models=""
p_table="
" | " execute "call " & p_models response.write " | "
if p_mode="more" then
response.write "
end if
if p_mode="page" then
response.write "
" call pagination(p_page,rs.recordCount,rs.pageCount,p_paginationMode) response.write " |
end if
end sub
end class
‘-------------------------------列表过程结束---------------------------response.End()
end if
end function
通过一下的两个函数可以实现图片,文字的同时提交处理。
Function BinaryToString(str)
strto = ""
for i=1 to lenb(str)
if AscB(MidB(str, i, 1)) > 127 then
strto = strto & chr(Ascb(MidB(str, i, 1))*256+Ascb(MidB(str, i+1, 1)))
i = i + 1
else
strto = strto & Chr(AscB(MidB(str, i, 1)))
end if
next
BinaryToString=strto
End Function
function gainformdata(n)
dim formsize,formdata,divider,datastart,dataend
redim mydata(n-1)
formsize = Request.TotalBytes
formdata = Request.BinaryRead(formsize)
for i=1 to n
bncrlf = chrB(13) & chrB(10)
divider = leftB(formdata,clng(instrB(formdata,bncrlf))-1)
datastart = instrB(formdata,bncrlf & bncrlf)+4
dataend = instrB(datastart+1,formdata,divider) - datastart-2
mydata(i-1) = midB(formdata,datastart,dataend)
formdata=rightB(formdata,clng(formsize-instrB(datastart+1,formdata,divider))+1)
formsize=lenB(formdata)
next
gainformdata=mydata
end function
Demo:
a.htm:
b.asp:
‘链接数据库
data=gainfromdata(2)
rs("txt")=binarytostring(data(0))
rs("img").appendchunk=data(1)
‘==================================================================--
‘
‘ 用ASP实现无组件上传/下载文件
‘
‘ 功能简介
‘ 将上传的文件数据保存到数据库中,可以处理表单中的多个上传文件的情况
‘ 适用于各种数据库,使用ADO的方法连接数据库
‘ 本示例中使用的是ACCESS数据库:zj.mdb
‘ 表:tb_img(id int(自增列),path text(255) 保存上传文件的目录
‘ ,fname text(250) 保存上传的文件名,type test(250) 保存上传文件的类型
‘ ,img ole对象 保存上传的文件内容
‘
‘ 邹建 2003.10
‘==================================================================
‘==================================================================
‘
‘ 上传文件的HTML页: zj_up.htm
‘
‘==================================================================
‘==================================================================
‘
‘ 上传文件保存到数据库的ASP页: zj_up.asp
‘
‘==================================================================
<%
Response.Expires=0
Function f_Bin2Str(ByVal sBin)
Dim iI, iLen, iChr, iRe
iRe = ""
If Not IsNull(sBin) Then
iLen = LenB(sBin)
For iI = 1 To iLen
iChr = MidB(sBin, iI, 1)
If AscB(iChr) > 127 Then
iRe = iRe & Chr(AscW(MidB(sBin, iI + 1, 1) & iChr))
iI = iI + 1
Else
iRe = iRe & Chr(AscB(iChr))
End If
Next
End If
f_Bin2Str = iRe
End Function
iConcStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False" & _
";Data Source=" & server.mappath("zj.mdb")
iSql="tb_img"
set iRe=Server.CreateObject("ADODB.Recordset")
iRe.Open iSql,iConcStr,1,3
iLen=Request.TotalBytes
sBin=Request.BinaryRead(iLen)
iCrlf1 = ChrB(13) & ChrB(10)
iCrlf2 = iCrlf1 & iCrlf1
iLen = InStrB(1, sBin, iCrlf1) - 1
iSpc = LeftB(sBin, iLen)
sBin = MidB(sBin, iLen + 34)
iPos1 = InStrB(sBin, iCrlf2) - 1
While iPos1 > 0
iStr = f_Bin2Str(LeftB(sBin, iPos1))
iPos1 = iPos1 + 5
iPos2 = InStrB(iPos1, sBin, iSpc)
iPos3 = InStr(iStr, "; filename=""") + 12
If iPos3 > 12 Then
iStr = Mid(iStr, iPos3)
iPos3 = InStr(iStr, Chr(13) & Chr(10) & "Content-Type: ") - 2
iFn = Left(iStr, iPos3)
If iFn <> "" Then
iRe.AddNew
ire("path")=left(iFn,instrrev(iFn,"\"))
iRe("fname") = mid(iFn,instrrev(iFn,"\")+1)
iRe("type") = Mid(iStr, iPos3 + 18)
iRe("img").AppendChunk MidB(sBin, iPos1, iPos2 - iPos1)
iRe.Update
End If
End If
sBin = MidB(sBin, iPos2 + iLen + 34)
iPos1 = InStrB(sBin, iCrlf2) - 1
Wend
iRe.close
set iRe=Nothing
%>
‘==================================================================
‘
‘ 下载数据的ASP页: zj_down.asp
‘
‘==================================================================
<%
Response.Buffer=true
Response.Clear
iConcStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False" & _
";Data Source=" & server.mappath("zj.mdb")
set iRe=server.createobject("adodb.recordset")
iSql="tb_img"
iRe.open iSql,iconcstr,1,1
Response.ContentType=ire("type")
Response.BinaryWrite iRe("img")
iRe.close
set iRe=Nothing
%>
弹出提示信息 , 确定 与 取消 怎么做的
onclick="{if(confirm(‘确定删除选定的纪录吗?‘)){this.document.inbox.submit();return true;}return false;}"
6. 组合查询的优化,谢谢
sql = "select * from book where bname like ‘%" & txtbname.Text & "%‘ and bauthor like ‘%" & txtauthor.Text & "%‘ and bpublish like ‘%" & txtpublish.Text & "%‘ and bdescription like ‘%" & txtdescription.Text & "%‘ order by bookid desc"
组合查询,有是四个组合条件,这样写是不是效率比较低,我该怎么优化一下呢?
谢谢。
分析,在SQL中,用LIKE是比较费时间的,所以最好是少用。
同时 ,四个TEXT框,输入条件是,一定会有没有输入的条件的时候,就会出现 LIKE "%"的情况,其实这种情况下就等于这个条件没有。
所以,把生成SQL语句的代码多写些,
Dim WhereStr as string
if txtbname.Text<>"" then
WhereStr="bname like ‘%" & txtbname.Text & "%‘"
ELSE IF ....
.....
ENDIF
这样是一个概率的问题,如果四个全输入的话,是一样的,但如果只输入一个的问,速度会比你的快些!
sql = "select * from book where "
If txtbname.Text <> "" Then
sql = sql & "bname like ‘%" & txtbname.Text & "%‘"
ElseIf txtauthor.Text <> "" Then
sql = sql & "bauthor like ‘%" & txtauthor.Text & "%‘"
ElseIf txtpublish.Text <> "" Then
sql = sql & "bpublish like ‘%" & txtpublish.Text & "%‘"
ElseIf txtdescription.Text <> "" Then
sql = sql & "bdescription like ‘%" & txtdescription.Text & "%‘ "
End If
8.如何禁止刷新
页面已经禁止刷新
12.
sql server 用:sql = "update reg set dealtime=getdate() where id= " & request.querystring("id")
因为 SQL SERVER里没有 now() 这个函数,而是用 getdate() 取代了
所以你的会报错.
ACCESS没有这个函数:)
只有date()和now()
下载任何文件(尤其是IE关联打开的)
<%
Dim Stream
Dim Contents
Dim FileName
Dim FileExt
Const adTypeBinary = 1
FileName = Request.QueryString("FileName")
if FileName = "" Then
Response.Write "无效文件名."
Response.End
End if
‘ 下面是不希望下载的文件
FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)
Select Case UCase(FileExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB"
Response.Write "受保护文件,不能下载."
Response.End
End Select
‘ 下载这个文件
Response.Clear
Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition", "attachment; filename=" & FileName
Set Stream = server.CreateObject("ADODB.Stream")
Stream.Type = adTypeBinary
Stream.Open
Stream.LoadFromFile Server.MapPath(FileName)
While Not Stream.EOS
Response.BinaryWrite Stream.Read(1024 * 64)
Wend
Stream.Close
Set Stream = Nothing
Response.Flush
Response.End
%>