set rs=server.CreateObject("adodb.recordset") 的中文詳細(xì)說明
更新時(shí)間:2010年08月04日 13:09:32 作者:
這是創(chuàng)建一個(gè)數(shù)據(jù)庫實(shí)例,但是什么是數(shù)據(jù)庫實(shí)例?還有rs這個(gè)東西也不是一個(gè)變量,他在程序里邊rs.update 等操作是如何進(jìn)行的?打開的表示如何接收rs傳過來的數(shù)據(jù)的?
是建立一個(gè)數(shù)據(jù)集
前面應(yīng)該先定義此數(shù)據(jù)集
dim rs as adodb.recordset
然后就可以用
set rs=server.CreateObject("adodb.recordset")
來建立一個(gè)數(shù)據(jù)集的實(shí)例,當(dāng)然此時(shí)數(shù)據(jù)集中是沒有數(shù)據(jù)的
rs.open ......
來打開一個(gè)記錄集
rs.append或者rs.insert來添加記錄
rs.edit來修改記錄
對(duì)于添加或修改的記錄,可以用
rs.fields("字段名")=xxx
來進(jìn)行賦值
rs.update
把更改過的值更新回?cái)?shù)據(jù)庫
當(dāng)你添加一個(gè)數(shù)據(jù)(rs1)進(jìn)數(shù)據(jù)庫時(shí):
rs.addnew
rs("rs1")="添加的數(shù)據(jù)"
rs.update
rs.close
set rs=nothing
下面我們來個(gè)實(shí)例:
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
//下面是調(diào)用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">內(nèi)容是否公開:</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">回復(fù):</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=" 回復(fù)留言 " class="button">
<input name="reSet" type="reSet" id="reSet4" value=" 重新輸入 " class="button">
</td>
</tr>
</form>
</table>
前面應(yīng)該先定義此數(shù)據(jù)集
dim rs as adodb.recordset
然后就可以用
set rs=server.CreateObject("adodb.recordset")
來建立一個(gè)數(shù)據(jù)集的實(shí)例,當(dāng)然此時(shí)數(shù)據(jù)集中是沒有數(shù)據(jù)的
rs.open ......
來打開一個(gè)記錄集
rs.append或者rs.insert來添加記錄
rs.edit來修改記錄
對(duì)于添加或修改的記錄,可以用
rs.fields("字段名")=xxx
來進(jìn)行賦值
rs.update
把更改過的值更新回?cái)?shù)據(jù)庫
當(dāng)你添加一個(gè)數(shù)據(jù)(rs1)進(jìn)數(shù)據(jù)庫時(shí):
rs.addnew
rs("rs1")="添加的數(shù)據(jù)"
rs.update
rs.close
set rs=nothing
下面我們來個(gè)實(shí)例:
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
//下面是調(diào)用html輸入框
復(fù)制代碼 代碼如下:
<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">內(nèi)容是否公開:</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">回復(fù):</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=" 回復(fù)留言 " class="button">
<input name="reSet" type="reSet" id="reSet4" value=" 重新輸入 " class="button">
</td>
</tr>
</form>
</table>
相關(guān)文章
asp Access數(shù)據(jù)備份,還原,壓縮類代碼
asp Access數(shù)據(jù)備份,還原,壓縮類實(shí)現(xiàn)代碼,大家可以參考下。2009-11-11ASP在SQL Server 2000中新建帳號(hào)和權(quán)限
ASP在SQL Server 2000中新建帳號(hào)和權(quán)限...2006-09-09Asp Oracle存儲(chǔ)過程返回結(jié)果集的代碼
對(duì)于 Oracle 這個(gè)龐然大物,Asp使用起來,確實(shí)是捉襟見肘的 。 尤其是要返回結(jié)果集(Recordset)的情況,更是讓很多人犯難。2008-11-11asp 在線備份與恢復(fù)sqlserver數(shù)據(jù)庫的代碼
asp 在線備份 恢復(fù) sql server 數(shù)據(jù)庫,對(duì)于遠(yuǎn)程沒有提供sqlserver遠(yuǎn)程連接或打包下載的朋友是個(gè)臨時(shí)解決方法,對(duì)于大數(shù)據(jù)來說可能效果不好。2010-07-07