求asp插入记录,删除记录,修改记录的代码,要完全正确的,谢谢!
答案:1 悬赏:40 手机版
解决时间 2021-04-06 06:04
- 提问者网友:却不属于对方
- 2021-04-05 20:49
求asp插入记录,删除记录,修改记录的代码,要完全正确的,谢谢!
最佳答案
- 五星知识达人网友:痴妹与他
- 2021-04-05 22:11
链接数据库:
<%
dim conn
dim connstr
dim db
db="/DataBase/data.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn.Open connstr
%>
插入记录:
<%
set rs = server.CreateObject ("Adodb.recordset")
sql = "select * from [News]"
rs.Open sql,conn,1,3
rs.AddNew
rs("title") = Request("title")
rs("Keywords") = request("Keywords")
rs("Description") = Request("Description")
rs("adddate") = Now()
rs.Update
rs.Close
set rs=nothing
%>
删除记录:
<%
set rs = server.CreateObject ("adodb.recordset")
sql = "delete from [News] where id="&Cint(Request("id"))&""
conn.execute(sql)
set rs=nothing
%>
修改记录:
<%
sql="update [News] set [title]='"&Request("title")&"',[Keywords]='"&Request("Keywords")&"',[Description]='"&Request("Description")&"',adddate=Now() where id="&cint(request("id"))&""
conn.execute(sql)
%>
<%
dim conn
dim connstr
dim db
db="/DataBase/data.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn.Open connstr
%>
插入记录:
<%
set rs = server.CreateObject ("Adodb.recordset")
sql = "select * from [News]"
rs.Open sql,conn,1,3
rs.AddNew
rs("title") = Request("title")
rs("Keywords") = request("Keywords")
rs("Description") = Request("Description")
rs("adddate") = Now()
rs.Update
rs.Close
set rs=nothing
%>
删除记录:
<%
set rs = server.CreateObject ("adodb.recordset")
sql = "delete from [News] where id="&Cint(Request("id"))&""
conn.execute(sql)
set rs=nothing
%>
修改记录:
<%
sql="update [News] set [title]='"&Request("title")&"',[Keywords]='"&Request("Keywords")&"',[Description]='"&Request("Description")&"',adddate=Now() where id="&cint(request("id"))&""
conn.execute(sql)
%>
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯