asp快速開發(fā)方法之?dāng)?shù)據(jù)操作實例代碼第3/3頁
更新時間:2007年08月08日 11:05:52 作者:
當(dāng)然你也這以這樣寫:
<%
sql="insert into cnarticle(cn_title,cn_author,cn_content) values(' "&whattitle&" ',' "&whoauthor&" ',' "&whatcontent&" ')"
opendatabase
conn.execute(sql)
closedatabase
%>
考慮到可能刪除語句我們會這么寫:
sql="delect from cnarticle where id in(1,3,5,6,7,8)"
我新建一個類DeldataTable,直接使用DeldataTable.DeldataSql(tableName,DelField,id)完成記錄的刪除操作。
<%
Class DeldataTable
dim tempvalue
public Function DeldataSql(tableName,DelField,id)
If tableName<>"" and id<>"" then
sql="delete from "&tableName
If isnumeric(id) and instr(id,",")=0 then
sql = sql & " where "&DelField&" = "&id
Else
sql = sql & " where "&DelField&" in ("& id &")"
End If
Opendatabase
conn.execute(sql)
Closedatabase
tempvalue=true
Else
tempvalue=false
End If
DeldataSql=tempvalue
End Function
End Class
%>
以下是我的sql.asp文件,請自己進行增刪
復(fù)制代碼 <%
'用于查詢數(shù)據(jù)
Class selectDataTable
'查出記錄
public Function SelectData(sql)
If sql<>"" then
opendatabase
Rs.open sql,conn,1,1
If not Rs.eof then
Thedata=Rs.GetRows(-1)
Closedatabase
Else
Closedatabase
End If
End If
SelectData=Thedata
End Function
相關(guān)文章
asp 存貯過程 (SQL版asp調(diào)用存儲過程)
asp 存貯過程 (SQL版asp調(diào)用存儲過程)...2007-11-11Eval 函數(shù) | Execute 語句 | ExecuteGlobal 語句使用說明
在運行時添加過程和類是非常有用的,但是也可能導(dǎo)致在運行時覆蓋已有的全局 變量 和函數(shù)。因為這可能導(dǎo)致非常嚴重的程序問題,因此,當(dāng)使用 ExecuteGlobal 語句時一定得非常謹慎。2007-02-02ASP編程入門進階(二十):ADO組件之查詢數(shù)據(jù)記錄
ASP編程入門進階(二十):ADO組件之查詢數(shù)據(jù)記錄...2007-01-01IIS 錯誤 Server Application Error 詳細解決方法
IIS 錯誤 Server Application Error 詳細解決方法...2007-02-02