這是建立一個資料庫實例,但是什麼是資料庫實例?還有rs這個東西也不是一個變量,他在程式裡邊rs.update 等操作是如何進行的?開啟的表示如何接收rs傳過來的資料的?是建立一個資料集
前面應該先定義此資料集
dim rs as adodb.recordset
然後就可以用
set rs=server.CreateObject(adodb.recordset)
來建立一個資料集的實例,當然此時資料集中是沒有資料的
rs.open ......
來開啟一個記錄集
rs.append或rs.insert來新增記錄
rs.edit來修改記錄
對於新增或修改的記錄,可以用
rs.fields(字段名)=xxx
來進行賦值
rs.update
把更改過的值更新回資料庫
當你新增一個資料(rs1)進資料庫:
rs.addnew
rs(rs1)=新增的數據
rs.update
rs.close
set rs=nothing
下面我們來個實例:
Set mRs= Server.CreateObject(adodb.recordSet)
mRs.open Select * from book, conn, 1, 3
mRs.addnew
mRs(Name) = Name
mRs(Mail) = Mail
mRs(Qq) = Qq
mRs(Info) = Info
mRs(time) = now()
mRs.update
mRs.close
Set mRs = nothing
//下面是呼叫html輸入框
複製代碼代碼如下:
<table border=0 cellpadding=0 style=border-collapse: collapse width=100%>
<form name=form1 method=post action=admin/<% =filename %>?action=Reply&id=<% =id %>>
<tr>
<td width=118 height=37 align=center bgcolor=#EFEFEF>暱稱:</td>
<td width=640>
<input name=Name type=text class=input value=<% =mRs(Name) %>>
</td>
</tr>
<tr>
<td width=118 height=37 align=center bgcolor=#EFEFEF>內容是否公開:</td>
<td width=640>
<input type=radio name=Qq value=1 <%if mRs(qq)=1 then response.write checked end if%> >
是
<input name=Qq type=radio value=0 <%if mRs(qq)=0 then response.write checked end if%> >
否</td>
</tr>
<tr>
<td width=118 height=37 align=center bgcolor=#EFEFEF>信箱:</td>
<td width=640>
<input name=Mail type=text class=input value=<% =mRs(Mail) %>>
</td>
</tr>
<tr>
<td width=118 height=37 align=center bgcolor=#EFEFEF>留言:</td>
<td width=640>
<textarea name=Info rows=9 cols=57 class=button><% =mRs(Info) %></textarea>
</td>
</tr>
<tr>
<td height=25 align=center bgcolor=#EFEFEF width=118>回覆:</td>
<td height=100 rowspan=2 bgcolor=#EFEFEF width=640>
<textarea name=Reply rows=6 cols=50 class=button><% =Reply %></textarea>
</td>
</tr>
<tr>
<td height=70 bgcolor=#EFEFEF width=118></td>
</tr>
<tr>
<td height=20 colspan=2 align=center bgcolor=#EFEFEF>
<input name=Submit1 type=submit id=Submit value= 回覆留言class=button>
<input name=reSet type=reSet id=reSet4 value= 重新輸入class=button>
</td>
</tr>
</form>
</table>