<%
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!<a hre長科f=javascript:history.go(-1)>try司一 again</a>":response.end高農
age=clng(age)
end if '************************影信******************************喝廠**************
' 與AccessDB相關的連接信息
' 可以參照它建立您的數據庫連接
'*****************************麗銀*********************水服******************
Dim conn,rs,dbpath
Set conn=Server.CreateObject("ADODB.C來要onnection")
Set rs=Server.CreateObject("ADO要公DB.RecordSet")
dbpath=Server.MapPath("r就開wdata/db_test_com.mdb")
conn.Open "Driver={Microsoft A友花ccess Driver (*.mdb)}厭腦; DBQ="&dbpath
'*******************************暗行************************************做好*
'************************木那********************************歌樹************
dim strsql
'*******************************校他****************************章筆*********
' 讀數據庫相關操作
sub readdb()
strsql="select * from test小煙"
rs.open strsql,conn,1,1
if rs.EOF then response.write "no re章但cord at all":exit sub
response.write "<table border=1>下花"
response.write "<tr>"
for i=0 to rs.Fields.C機鄉ount-1
response.write "<td>司離;<font color=blue>"&rs.Fie鐵要lds(i).Name&"<拿門/font></td>"
next
response.write "</tr>"得習
while not rs.EOF
response.write "<tr>"
for i=0 to rs.Fields.Count-1
response.write "<td>"&rs.F樂遠ields(i).value&"</td>"
next
response.write "</tr>"
rs.MoveNext
wend
response.write "</table>"
rs.Close
end sub
'**********************湖店*********************音少*************************
'****************************答坐***********************到睡*****************
' 寫數據庫相關
sub insertdata()
strsql="INSERT INTO t愛熱est(name,age,addr) valueS('"&name&"',"&雨影;age&",'"&addr&"')"
rs.Open strsql,conn,1,3
end sub
'***********************************但但*********************************
if mode=1 then
call insertdata()
response.write "inser了資t ok!"
elseif mode=2 then
call readdb()
end if
'*********************************資道*******************************但爸****
' 釋放數據庫連接對象
set rs=nothing
set conn=nothing
%>
<HTML>
<HEAD>
<TITLE></TITLE>
<script language=javascript>
function clickit(flag){
var form1=document.for明那m2
form1.text4.value=flag;
if (flag==1){
if (form1.text1.value==""){
alert("name cant empty地玩!");
return false;
}
if (form1.text2.value==""){
alert("age cant empty!")愛鐵;
return false;
}
if (form1.text3.value==""){
alert("addr cant empty!");
return false;
}
}
form1.submit();
return true;
}
</script>
</HEAD>
<BODY>
<form method=post name=form2>
name:<INPUT type="text" id月話=text1 name=text1 size時女=12>
age:<INPUT type="t市服ext" id=text2 name=text2 size村時=12>
city:<INPUT type="text" id=有現text3 name=text3 size=12><br電新>
<INPUT type="hidden" id=te海木xt4 name=text4>
<INPUT type="button" value="write" id=button1 n了他ame=button1 onclick="clickit(1)">
<INPUT type="button" value="read" id=button2 nam體謝e=button2 onclick="clickit(2)">
</form>
</BODY>
</HTML>