ASP+ACCESS 温故而知新
set conn = server.CreateObject("ADODB.connection") conn.open "provider=microsoft.jet.oledb.4.0;data source="&Server.MapPath("../include/#test.mdb") dim action action = request.QueryString("action") '添加数据 if action = "add" then sql = "select * from Datas" set rs = server.CreateObject("ADODB.recordset") rs.open sql,conn,3,3 rs.addnew rs("xxx") = request.Form("xxx") … … rs.update response.write("<script type='text/javascript'>alert('添加成功!'); location.href=xxx.asp'</script>") rs.close set rs = nothing '修改数据 elseif action = "edit" then dim getID getID = request.QueryString("id") sql = "select * from Datas where id="&getID set rs = server.CreateObject("ADODB.recordset") rs.open sql,conn,3,3 rs("Name") = request.Form("Name") … … rs.update response.write("修改成功!") rs.close set rs = nothing '删除数据 elseif action = "del" then getID = request.QueryString("id") sql = "delete from Datas where id="&getID conn.execute(sql) response.write("<script type='text/javascript'>alert('已删除!'); location.href='admin.asp'</script>") end if conn.close set conn = nothing
QA1、数据可以读取,但是到了修改、添加、删除时都报错
- Mdb文件是否只读
- 存放mdb文件的磁盘格式是否为NTFS
欢迎在评论区留下你宝贵的意见,不论好坏都是我前进的动力(cnblogs 排名提升)!
如果喜欢,记得点赞、推荐、关注、收藏、转发 ... ;)