ASP新手必備的基礎知識
我們都知道,ASP是Active Server Page的縮寫,意為“動態(tài)服務器頁面”。ASP是微軟公司開發(fā)的代替CGI腳本程序的一種應用,它可以與數(shù)據(jù)庫和其它程序進行交互,是一種簡單、方便的編程工具。下面介紹一些基本知識,供大家參考。
一、數(shù)據(jù)庫連接
以下為引用的內(nèi)容:
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("數(shù)據(jù)庫名")
%>
二、打開數(shù)據(jù)庫
以下為引用的內(nèi)容:
exec="select * from 數(shù)據(jù)庫表"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
參數(shù)1,1為讀取
讀取內(nèi)容格式:<%=rs("字段")%>
三、添加記錄處理程序
以下為引用的內(nèi)容:
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("數(shù)據(jù)庫名")
name=request.form("字段") name,tel,message為提交表單所設置的字段值
tel=request.form("字段")
message=request.form("字段")
exec="insert into 表名(字段)values('"+字段+"')" 多個用逗號隔開
conn.execute exec 使用execute提交
conn.close
set conn=nothing
%>
四、搜索處理程序
以下為引用的內(nèi)容:
<%
name=request.form("字段") name,tel為提交表單所設置的字段值
tel=request.form("字段")
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("數(shù)據(jù)庫名")
exec="select * from 表 where name='"+字段+"' and tel="+字段
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
%>
'頁面搜索到的內(nèi)容導出來
<%
do while not rs.eof
%><tr>
<td><%=rs("name")%></td>
<td><%=rs("tel")%></td>
<td><%=rs("time")%></td>
</tr>
<%
rs.movenext
loop
%>
五、刪除記錄處理程序
以下為引用的內(nèi)容:
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("數(shù)據(jù)庫名")
exec="delete * from 表名 where 編號="&request.form("id")
conn.execute exec
%>
六、修改記錄處理程序
以下為引用的內(nèi)容:
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("數(shù)據(jù)庫名")
exec="select * from 表名 where 編號="&request.form("id")
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,3 '1,3為修改意思
rs("name")=request.form("字段") 'name,tel,message為提交表單所設置的字段值
rs("tel")=request.form("字段")
rs("message")=request.form("字段")
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
修改記錄執(zhí)行程序:輸入ID號頁面>>>導出相對應ID數(shù)據(jù)>>>>>>直接修改的處理程序
七、后臺登陸處理程序例子
以下為引用的內(nèi)容:
<%
dim name,password
name=request.form("name")
password=request.form("password")
dim exec,conn,rs
exec="select *from 表名 where(name='"&字段&"' and password='"&字段&"')"
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("數(shù)據(jù)庫名")
set rs=server.createobject("adodb.recordset")
rs.open exec,conn
if not rs.eof then
rs.Close
conn.Close
session("checked")="yes"
session("check")="right"
response.Redirect "index.asp"
else
session("checked")="no"
session("check")="wrong"
response.Redirect "login.asp"
end if
%>
每個后臺頁面加上:
<%if not session("checked")="yes" then 'session里面定義一個checked字符串變量
response.Redirect "login.asp"
else
%>
希望以上對于ASP基礎知識的介紹,能給初學者帶來一定的幫助。
上一篇:ASP實現(xiàn)加法驗證碼
欄 目:ASP編程
下一篇:沒有了
本文標題:ASP新手必備的基礎知識
本文地址:http://www.jygsgssxh.com/a1/ASPbiancheng/11382.html
您可能感興趣的文章
- 01-11ASP實現(xiàn)加法驗證碼
- 01-11asp服務器如何搭建
- 01-11ASP腳本組件實現(xiàn)服務器重啟
- 01-11ASP動態(tài)網(wǎng)頁制作技術(shù)經(jīng)驗分享
- 01-11ASP實現(xiàn)類似hashMap功能的類
- 01-11ASP編碼必備的8條原則
- 01-11解決ASP中http狀態(tài)跳轉(zhuǎn)返回錯誤頁的問題
- 01-11ASP程序中常用的腳本語言
- 01-11ASP中用select case代替其他語言中的switch case, default用case else
- 01-11asp實現(xiàn)限制一個ip只能訪問一次的方法


閱讀排行
本欄相關
- 01-11ASP實現(xiàn)加法驗證碼
- 01-11ASP新手必備的基礎知識
- 01-11ASP腳本組件實現(xiàn)服務器重啟
- 01-11asp服務器如何搭建
- 01-11ASP實現(xiàn)類似hashMap功能的類
- 01-11ASP動態(tài)網(wǎng)頁制作技術(shù)經(jīng)驗分享
- 01-11解決ASP中http狀態(tài)跳轉(zhuǎn)返回錯誤頁的問
- 01-11ASP編碼必備的8條原則
- 01-11ASP中用select case代替其他語言中的sw
- 01-11ASP程序中常用的腳本語言
隨機閱讀
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 01-10使用C語言求解撲克牌的順子及n個骰子
- 04-02jquery與jsp,用jquery
- 01-10C#中split用法實例總結(jié)
- 01-10SublimeText編譯C開發(fā)環(huán)境設置
- 08-05織夢dedecms什么時候用欄目交叉功能?
- 01-10delphi制作wav文件的方法
- 01-11ajax實現(xiàn)頁面的局部加載
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文


