自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

ASP新手之常用源代碼的總結(jié)(下)

開發(fā) 后端
本文介紹的是一些ASP程序設計中經(jīng)常用到的源代碼。適合初學者閱讀。希望對你有幫助,一起來看吧!

ASP是Active Server Page的縮寫,意為“動態(tài)服務器頁面”。ASP是微軟公司開發(fā)的代替CGI腳本程序的一種應用,它可以與數(shù)據(jù)庫和其它程序進行交互,是一種簡單、方便的編程工具。接上篇>>

11.ACCESS數(shù)據(jù)庫連接:

  1. <%   
  2. option explicit   
  3. dim startime,endtime,conn,connstr,db   
  4. startime=timer()   
  5. '更改數(shù)據(jù)庫名字   
  6. db="data/dvBBS5.mdb"   
  7. Set conn = Server.CreateObject("ADODB.Connection")   
  8. connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)   
  9. '如果你的服務器采用較老版本Access驅(qū)動,請用下面連接方法   
  10. 'connstr="driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath(db)   
  11. conn.Open connstr   
  12. function CloseDatabase   
  13. Conn.close   
  14. Set conn = Nothing   
  15. End Function   
  16. %> 

12.SQL數(shù)據(jù)庫連接:

  1. <%   
  2. option explicit   
  3. dim startime,endtime,conn,connstr,db   
  4. startime=timer()   
  5. connstr="driver={SQL Server};server=HUDENQ-N11T33NB;uid=sa;pwd=xsfeihu;database=dvbbs"   
  6. Set conn = Server.CreateObject("ADODB.Connection")   
  7. conn.Open connstr   
  8. function CloseDatabase   
  9. Conn.close   
  10. Set conn = Nothing   
  11. End Function   
  12. %> 

13.用鍵盤打開網(wǎng)頁代碼: 

  1. <script language="javascript">   
  2. function ctlent(eventobject)   
  3. {   
  4. if((event.ctrlKey && window.event.keyCode==13)||(event.altKey && window.event.keyCode==83))   
  5. {   
  6. window.open('網(wǎng)址','','')   
  7. }   
  8. }   
  9. </script> 

這里是Ctrl+Enter和Alt+S的代碼 自己查下鍵盤的ASCII碼再換就行

14.讓層不被控件復蓋代碼:

  1. <div z-Index:2><object xxx></object></div> # 前面   
  2. <div z-Index:1><object xxx></object></div> # 后面   
  3. <div id="Layer2" style="position:absolute; top:40;width:400px; height:95px;z-index:2">
  4. <table height=100% width=100% bgcolor="#ff0000"><tr>
  5. <td height=100% width=100%></td></tr></table><iframe width=0 height=0></iframe></div>   
  6. <div id="Layer1" style="position:absolute; top:50;width:200px; height:115px;z-index:1">
  7. <iframe height=100% width=100%></iframe></div> 

15.動網(wǎng)FLASH廣告代碼:

  1. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"   
  2. codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0
  3.  width="468" height="60"> 
  4. <param name=movie value="images/yj16d.swf"> 
  5. <param name=quality value=high> 
  6. <embed src="images/dvbanner.swf" quality=high 
  7. pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash;
  8. ;;;;;;;;;;; type="application/x-shockwave-flash" width="468" height="60"></embed></object>  

16.VBS彈出窗口小代碼:

  1. <script language=vbscript>   
  2. msgbox"你還沒有注冊或登陸論壇","0","精品論壇"   
  3. location.href = "login.asp"   
  4. </script> 

17.使用FSO修改文件特定內(nèi)容的函數(shù):

 

  1. function FSOchange(filename,Target,String)   
  2. Dim objFSO,objCountFile,FiletempData   
  3. Set objFSO = Server.CreateObject("Scripting.FileSystemObject")   
  4. Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)   
  5. FiletempData = objCountFile.ReadAll   
  6. objCountFile.Close   
  7. FiletempData=Replace(FiletempData,Target,String)   
  8. Set objCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True)   
  9. objCountFile.Write FiletempData   
  10. objCountFile.Close   
  11. Set objCountFile=Nothing   
  12. Set objFSO = Nothing   
  13. End Function 

 

18.使用FSO讀取文件內(nèi)容的函數(shù):

 

  1. function FSOFileRead(filename)   
  2. Dim objFSO,objCountFile,FiletempData   
  3. Set objFSO = Server.CreateObject("Scripting.FileSystemObject")   
  4. Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)   
  5. FSOFileRead = objCountFile.ReadAll   
  6. objCountFile.Close   
  7. Set objCountFile=Nothing   
  8. Set objFSO = Nothing   
  9. End Function 

 

19.使用FSO讀取文件某一行的函數(shù):

 

  1. function FSOlinedit(filename,lineNum)   
  2. if linenum < 1 then exit function   
  3. dim fso,f,temparray,tempcnt   
  4. set fso = server.CreateObject("scripting.filesystemobject")   
  5. if not fso.fileExists(server.mappath(filename)) then exit function   
  6. set f = fso.opentextfile(server.mappath(filename),1)   
  7. if not f.AtEndofStream then   
  8. tempcnt = f.readall   
  9. f.close   
  10. set f = nothing   
  11. temparray = split(tempcnt,chr(13)&chr(10))   
  12. if lineNum>ubound(temparray)+1 then   
  13. exit function   
  14. else   
  15. FSOlinedit = temparray(lineNum-1)   
  16. end if   
  17. end if   
  18. end function 

20.使用FSO修改文件特定內(nèi)容的函數(shù):

 

  1. function FSOchange(filename,Target,String)   
  2. Dim objFSO,objCountFile,FiletempData   
  3. Set objFSO = Server.CreateObject("Scripting.FileSystemObject")   
  4. Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)   
  5. FiletempData = objCountFile.ReadAll   
  6. objCountFile.Close   
  7. FiletempData=Replace(FiletempData,Target,String)   
  8. Set objCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True)   
  9. objCountFile.Write FiletempData   
  10. objCountFile.Close   
  11. Set objCountFile=Nothing   
  12. Set objFSO = Nothing   
  13. End Function 

 

21.使用FSO讀取文件內(nèi)容的函數(shù):

 

  1. function FSOFileRead(filename)   
  2. Dim objFSO,objCountFile,FiletempData   
  3. Set objFSO = Server.CreateObject("Scripting.FileSystemObject")   
  4. Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)   
  5. FSOFileRead = objCountFile.ReadAll   
  6. objCountFile.Close   
  7. Set objCountFile=Nothing   
  8. Set objFSO = Nothing   
  9. End Function 

 

22.使用FSO讀取文件某一行的函數(shù):

 

  1. function FSOlinedit(filename,lineNum)   
  2. if linenum < 1 then exit function   
  3. dim fso,f,temparray,tempcnt   
  4. set fso = server.CreateObject("scripting.filesystemobject")   
  5. if not fso.fileExists(server.mappath(filename)) then exit function   
  6. set f = fso.opentextfile(server.mappath(filename),1)   
  7. if not f.AtEndofStream then   
  8. tempcnt = f.readall   
  9. f.close   
  10. set f = nothing   
  11. temparray = split(tempcnt,chr(13)&chr(10))   
  12. if lineNum>ubound(temparray)+1 then   
  13. exit function   
  14. else   
  15. FSOlinedit = temparray(lineNum-1)   
  16. end if   
  17. end if   
  18. end function 

 

到此,關于ASP常用代碼的總結(jié)篇,就為大家介紹完了。希望對大家有幫助。

【編輯推薦】

  1. ASP.NET的HTTP模塊和處理程序之對話狀態(tài)
  2. ASP.NET配置文件Web.config詳細解釋
  3. 使用gettext技術為ASP.NET網(wǎng)站實現(xiàn)國際化支持
  4. 大型高性能ASP.NET系統(tǒng)架構(gòu)設計
  5. 詳解ASP.NET MVC 3中View的變化
責任編輯:于鐵 來源: 互聯(lián)網(wǎng)
相關推薦

2011-07-06 14:43:41

ASP

2011-07-06 16:45:40

2011-07-06 15:04:41

ASP

2009-08-25 17:42:41

ASP.NET新手問題

2010-08-03 10:16:52

Flex源代碼

2009-07-30 14:32:18

ASP.NET常用代碼

2009-04-02 11:00:09

微軟ASP.NETMVC

2009-07-30 14:26:30

ASP.NET常用代碼

2011-07-22 16:11:12

java

2010-06-10 10:31:36

MySQL出錯代碼列表

2010-06-02 10:26:06

SVN源代碼管理

2010-05-17 09:45:00

subversion源

2010-05-17 13:11:07

Subversion安

2009-07-22 11:00:30

ASP.NET MVC

2009-09-28 11:42:21

KestrelScala

2024-04-26 12:29:36

2009-10-26 16:53:00

VB.NET常用代碼

2010-05-17 13:22:37

Subversion安

2009-04-03 08:28:39

2010-07-22 11:01:41

SQL Server
點贊
收藏

51CTO技術棧公眾號