この記事では、ASPプログラミングでよく使用されるソースコードを共有します。初心者が読むのに適しています。それがあなたに役立つことを願っています、一緒に見てみましょう!
ASPは、Dynamic Serverページを意味するActive Serverページの略語です。 ASPは、CGIスクリプトプログラムを置き換えるためにMicrosoftによって開発されたアプリケーションです。前の記事>> http://www.vevb.com/kaifa/asp/70602.html
11.Accessデータベース接続:
- <%
- optionexplicit
- dimstArtime、endtime、conn、connstr、db
- starttime = timer()
- 'データベース名を変更します
- db = data/dvbbs5.mdb
- setConn = server.createObject(adodb.Connection)
- connstr = provider = microsoft.jet.oledb.4.0; dataSource =&server.mappath(db)
- 'サーバーがアクセスドライバーの古いバージョンを使用している場合は、次の接続方法を使用してください
- 'connstr = driver = {microsoft accessdriver(*。MDB)}; dbq =&server.mappath(db)
- conn.openconnstr
- functionclosedatabase
- conn.close
- setConn =何もない
- エンド機能
- %>
12.SQLデータベース接続:
- <%
- optionexplicit
- dimstArtime、endtime、conn、connstr、db
- starttime = timer()
- connstr = driver = {sqlserver}; server = hudenq-n11t33nb; uid = sa; pwd = xsfeihu; database = dvbbs
- setConn = server.createObject(adodb.Connection)
- conn.openconnstr
- functionclosedatabase
- conn.close
- setConn =何もない
- エンド機能
- %>
13.キーボードでWebページコードを開く:
- <ScriptLanguage = JavaScript>
- functionctlent(eventObject)
- {
- if((event.ctrlkey && window.event.keycode == 13)||(event.altkey&window.event.keycode == 83)))))
- {
- window.open( 'webサイト'、 ''、 '')
- }
- }
- </script>
Ctrl+EnterとAlt+Sのコードは自分で並べてから変更します。
14.コントロールコードによってレイヤーが上書きされないようにします。
- <divz-index:2> <objectxxx> </object> </div> #front
- <divz-index:1> <objectxxx> </object> </div> #back
- <divid = layer2style = position:absolute; top:40; width:400px; height:95px; z-index:2>
- <tableheight = 100%幅= 100%bgcolor =#ff0000> <tr>
- <tdheight = 100%幅= 100%> </td> </tr> </table> <iframewidth = 0height = 0> </iframe> </div>
- <divid = layer1style = position:absolute; top:50; width:200px; height:115px; z-index:1>
- <iframeheight = 100%width = 100%> </iframe> </div>
15.Dongwang Flash Advertisingコード:
- <objectClassID = CLSID:D27CDB6E-AE6D-11CF-96B8-44453540000
- codebase = http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version = 5,0,0,0
- width = 468height = 60>
- <paramname = movievalue = images/yj16d.swf>
- <paramname = qualityvalue = high>
- <bedsrc = images/dvbanner.swfquality = high
- PluginsPage = http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version = shockwaveflash;
- ;;;;;;;;
16.VBSポップアップウィンドウコード:
- <scriptlanguage = vbscript>
- MSGBOXフォーラムに登録またはログインしていない、0、ブティックフォーラム
- location.href = login.asp
- </script>
17. FSOを使用して、ファイル固有のコンテンツ関数を変更します。
- functionfsochange(ファイル名、ターゲット、文字列)
- dimobjfso、objcountfile、filetempdata
- setobjfso = server.createobject(scripting.filesystemobject)
- setobjcountfile = objfso.opentextfile(server.mappath(filename)、1、true)
- filetempdata = objcountfile.readall
- objcountfile.close
- filetempdata =置換(filetempdata、ターゲット、文字列)
- setobjcountfile = objfso.createTextfile(server.mappath(filename)、true)
- objcountfile.writefiletempdata
- objcountfile.close
- setobjcountfile = Nothing
- setobjfso =何もない
- エンド機能
18。FSOを使用してファイルコンテンツを読み取る関数:
- functionfsofileread(filename)
- dimobjfso、objcountfile、filetempdata
- setobjfso = server.createobject(scripting.filesystemobject)
- setobjcountfile = objfso.opentextfile(server.mappath(filename)、1、true)
- fsofileread = objcountfile.readall
- objcountfile.close
- setobjcountfile = Nothing
- setobjfso =何もない
- エンド機能
19。FSOを使用してファイルの特定の行を読み取る関数:
- functionfsolinedit(filename、linenum)
- iflinenum <1thenexitfunction
- dimfso、f、temparray、tempcnt
- setFSO = server.createObject(scripting.filesystemObject)
- ifnotfso.fileexists(server.mappath(filename))thenexitfunction
- setf = fso.opentextfile(server.mappath(filename)、1)
- ifnotf.atendofstreamthen
- tempcnt = f.readall
- f.close
- setf = Nothing
- テンプレート= split(tempcnt、chr(13)&chr(10))
- iflinenum> ubund(temparray)+1then
- exitFunction
- それ以外
- fsolinedit = temparray(linenum-1)
- endif
- endif
- エンド機能
20。FSOを使用してファイル固有のコンテンツを変更する関数:
- functionfsochange(ファイル名、ターゲット、文字列)
- dimobjfso、objcountfile、filetempdata
- setobjfso = server.createobject(scripting.filesystemobject)
- setobjcountfile = objfso.opentextfile(server.mappath(filename)、1、true)
- filetempdata = objcountfile.readall
- objcountfile.close
- filetempdata =置換(filetempdata、ターゲット、文字列)
- setobjcountfile = objfso.createTextfile(server.mappath(filename)、true)
- objcountfile.writefiletempdata
- objcountfile.close
- setobjcountfile = Nothing
- setobjfso =何もない
- エンド機能
21。FSOを使用してファイルの内容を読み取る関数
:
- functionfsofileread(filename)
- dimobjfso、objcountfile、filetempdata
- setobjfso = server.createobject(scripting.filesystemobject)
- setobjcountfile = objfso.opentextfile(server.mappath(filename)、1、true)
- fsofileread = objcountfile.readall
- objcountfile.close
- setobjcountfile = Nothing
- setobjfso =何もない
- エンド機能
22。FSOを使用してファイルの特定の行を読み取る関数:
- functionfsolinedit(filename、linenum)
- iflinenum <1thenexitfunction
- dimfso、f、temparray、tempcnt
- setFSO = server.createObject(scripting.filesystemObject)
- ifnotfso.fileexists(server.mappath(filename))thenexitfunction
- setf = fso.opentextfile(server.mappath(filename)、1)
- ifnotf.atendofstreamthen
- tempcnt = f.readall
- f.close
- setf = Nothing
- テンプレート= split(tempcnt、chr(13)&chr(10))
- iflinenum> ubund(temparray)+1then
- exitFunction
- それ以外
- fsolinedit = temparray(linenum-1)
- endif
- endif
- エンド機能
この時点で、一般的に使用されるASPコードの要約でそれを紹介します。