用戶(hù)登陸

網(wǎng)站相關(guān)幫助

網(wǎng)站制作
模版設(shè)置
網(wǎng)站編輯
網(wǎng)站欄目設(shè)置
手機(jī)網(wǎng)站
微信網(wǎng)站
發(fā)布網(wǎng)站
模塊操作
系統(tǒng)管理
常見(jiàn)問(wèn)題

幫助文檔

ASP連接access數(shù)據(jù)庫(kù)例程
ASP連接access數(shù)據(jù)庫(kù)例程
注意:要運(yùn)行上述ACCESS例程請(qǐng)先下載數(shù)據(jù)庫(kù),放在db 或 rwdata文件夾下。請(qǐng)將例程放在根目錄下。
<%
Dim mode
mode=request.form("text4")
if mode=1 then
name=request.form("text1")
age=request.form("text2")
addr=request.form("text3")
if not isnumeric(age) then response.write "age must be number!try again":response.end
age=clng(age)
end if
'********************************************************************
' 與AccessDB相關(guān)的連接信息
' 可以參照它建立您的數(shù)據(jù)庫(kù)連接
'********************************************************************
Dim conn,rs,dbpath
Set conn=Server.CreateObject("ADODB.Connection")
Set rs=Server.CreateObject("ADODB.RecordSet")
dbpath=Server.MapPath("rwdata/db_test_com.mdb")
conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ="&dbpath
'********************************************************************
'********************************************************************

dim strsql
'********************************************************************
' 讀數(shù)據(jù)庫(kù)相關(guān)操作
sub readdb()
strsql="select * from test"
rs.open strsql,conn,1,1
if rs.EOF then response.write "no record at all":exit sub
response.write "

"
response.write "
"
for i=0 to rs.Fields.Count-1
response.write "
"
next
response.write "
"
while not rs.EOF
response.write "
"
for i=0 to rs.Fields.Count-1
response.write "
"
next
response.write "
"
rs.MoveNext
wend
response.write "
"&rs.Fields(i).Name&"
"&rs.Fields(i).Value&"
"
rs.Close
end sub
'********************************************************************


'********************************************************************
' 寫(xiě)數(shù)據(jù)庫(kù)相關(guān)
sub insertdata()
strsql="INSERT INTO test(name,age,addr) VALUES('"&name&"',"&age&",'"&addr&"')"
rs.Open strsql,conn,1,3
end sub
'********************************************************************

if mode=1 then
call insertdata()
response.write "insert ok!"
elseif mode=2 then
call readdb()
end if

'********************************************************************
' 釋放數(shù)據(jù)庫(kù)連接對(duì)象
set rs=nothing
set conn=nothing
%>







name:
age:
city:






注意:要運(yùn)行上述ACCESS例程請(qǐng)先下載數(shù)據(jù)庫(kù),放在rwdata文件夾下。請(qǐng)將例程放在根目錄下。

上一篇:空間生效后如何通過(guò)flashfxp上傳網(wǎng)頁(yè)?       下一篇:空間生效后如何通過(guò)Leapftp上傳網(wǎng)頁(yè)?

備案系統(tǒng)認(rèn)證 舉報(bào)不良網(wǎng)站 我們的支付方式 AAA級(jí)信用
廣州萬(wàn)戶(hù)網(wǎng)絡(luò)信息科技有限公司 旗下網(wǎng)站建設(shè)品牌:中外商貿(mào) verifyconference.com 版權(quán)所有 ©2000-2019 All Rights Reserved
網(wǎng)站備案編號(hào):粵ICP備15049595號(hào) 地址:廣州市番禺區(qū)大石街北聯(lián)圍仔工業(yè)路2號(hào)E座305
電話(huà):020-85421558   傳真:020-88140140   郵編:510515
交換PR>=4的友情鏈接合作站,歡迎同行聯(lián)系鏈接QQ: