欢迎分享,转载请注明来源:内存溢出
你要想通过这样在查询视图中能够删除某个表的记录那么你要删除的表的字段要完整并且要用这个表包含其他表字段的关系来设置……前提还是你要删除的记录不能有字段被其他表引用……根据你的各表在关系视图中建立的关系不同具体细节上会有所不同………………另外,数据库事实上是最忌会经常删除记录的……除非特别需要否则一般是修改记录内容或者一直保留历史记录(比如你的这条记录发现某个值错误了就去修改除非你要整理你的数据库而把历史冗余的数据删除),如果你一定要删除数据而减少数据存储空间的话,你要照顾到各表间的约束关系……一般是可以随意删除的记录都是没有被其他表引用的最低层的数据表中的记录……更详细的你参看帮助!在满足关系方向、字段数完整的查询结果的情况下才可以选中某几行数据进行删除……(一般来说这样要删除记录的情况你最好不显示其他表的字段,只用要删除记录表的字段powered by 25175net如何 *** 作Access数据库? 一、查找记录findhtm<HTML><HEAD><TITLE> Access数据库记录查找</TITLE></HEAD><BODY><FORM ACTION="findasp" METHOD="POST" id=form1 name=form1> 请输入您要查找的人的姓名: <BR> <INPUT TYPE="TEXT" NAME="man" SIZE=50><BR><BR> <INPUT TYPE="submit" NAME="send" VALUE="他/她的id是多少"></FORM></BODY></HTML>findasp<% Option Explicit%><!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common Files\System\ado\msado15dll" --><HTML><BODY><% Dim strman, strfind , objConn strman = RequestForm("man") Dim objRS Set objconn = ServerCreateObject("ADODBConnection") set objRS = ServerCreateObject("ADODBRecordset") objConnOpen("DRIVER={Microsoft Access Driver (mdb)}; DBQ=" & ServerMapPath("Manmdb"))objRSOpen "Names", objConn, adOpenStatic, adLockReadOnly, adCmdTable strfind = "Name='" & strman & "'" objRSFind strfind' 显示第一条相关记录 If objRSEOF Then ResponseWrite "哦,没有找到您要查找的人!" & _ strman Else ResponseWrite "他/她的姓名是: " & strman & "" & _ "Id是:" & objRS("ID") & "<BR>" & _ End If objRSClose Set objRS = Nothing objConnClose Set objConn = Nothing%></BODY></HTML> 二、过滤记录filterasp<% Option Explicit%><!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common Files\System\ado\msado15dll" --><HTML><HEAD><TITLE>精彩春风之Access数据库记录过滤</TITLE></HEAD><BODY> <% Dim objRS, intLetter, strChar, strCriteria objConnSet objConn = ServerCreateObject("ADODBConnection")Set objRS = ServerCreateObject("ADODBRecordset") objConnOpen("DRIVER={Microsoft Access Driver (mdb)}; DBQ=" & ServerMapPath("Manmdb")) objRSOpen "Names", objConn, adOpenStatic, adLockReadOnly, adCmdTable For intLetter = 1 To 26 strChar = Chr(intLetter+64) strCriteria = "Title LIKE '" & strChar & "'" objRSFilter = strCriteria If Not objRSEOF Then ResponseWrite "<H2>" & strChar & "</H2>" & _ "<TABLE BORDER=1><TR><TD><B>姓名<B></TD><TD>ID</TD></TR>" While Not objRSEOF ResponseWrite "<TR><TD>" & objRS("Name") & "</TD>" & _ "<TD>" & objRS("ID") & "</TD></TR>" objRSMoveNext Wend ResponseWrite "</TABLE>" End If Next objRSClose Set objRS = NothingobjConnClose Set objConn = Nothing%></BODY></HTML> 三、添加记录addasp<% Option Explicit%><!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common Files\System\ado\msado15dll" --><HTML><HEAD><TITLE>精彩春风之Access数据库记录添加</TITLE></HEAD><BODY><% Dim objRS, intIDForNewRecord , objConnSet objConn = ServerCreateObject("ADODBConnection")set objRS = ServerCreateObject("ADODBRecordset") objConnOpen("DRIVER={Microsoft Access Driver (mdb)}; DBQ=" & ServerMapPath("Manmdb"))' 连接数据库 objRSOpen "Names", objConn, adOpenStatic, adLockOptimistic, adCmdTable objRSMoveLast intIDForNewRecord = objRS("ID") + 1 objRSAddNew' 添加新记录 objRS("ID") = intIDForNewRecord objRS("Names") = "ManD" objRSUpdate objRSClose objRSOpen "SELECT FROM Names WHERE ID=" & intIDForNewRecord, _ ObjConn, adOpenForwardOnly, adLockReadOnly, adCmdText If objRSEOF Then ResponseWrite "噢,出错了!新记录没找到" Else ResponseWrite "恭喜,添加成功!新记录是:<BR> " & _ "Name = '" & objRS("Name") & "'<BR>" & _ "ID = '" & objRS("ID") & "'<BR>" End If objRSClose Set objRS = Nothing objConnClose' 清空 Set objConn = Nothing%></BODY></HTML>四、更新记录和上面的“添加记录”一样,只需把“添加”命令改做“更新”就可以了:objRSUpdate 五、删除记录This is the asp page, we will delete the record that we added ManD:<% Option Explicit%><!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common Files\System\ado\msado15dll" --><HTML><HEAD><TITLE> Access数据库记录删除</TITLE></HEAD><BODY><% Dim objRS, intIDForNewRecord, objConnSet objConn = ServerCreateObject("ADODBConnection")set objRS = ServerCreateObject("ADODBRecordset") objConnOpen("DRIVER={Microsoft Access Driver (mdb)}; DBQ=" & ServerMapPath("Manmdb")) objRSOpen "Names", objConn, adOpenStatic, adLockOptimistic, adCmdTable objRSFilter = "Name = ' ManD'" ResponseWrite "注意,以下记录将被删除:<BR> " While Not objRsEOF ResponseWrite objRS("ID") & "<BR>" objRSDelete objRSMoveNext Wend objRSClose ResponseWrite "<BR>核实删除记录:<BR>" objRSOpen "SELECT FROM Names WHERE Name LIKE 'ManD'", _ objConn, adOpenForwardOnly, adLockReadOnly, adCmdText If objRSEOF Then ResponseWrite "ManD的所有记录都已被从数据库删除!<BR> " Else ResponseWrite "噢,删除失败!ManD的记录还在数据库里呢, " & _ "ID=" & objRS("ID") End If objRSClose Set objRS = Nothing objConnClose Set objConn = Nothing%></BODY></HTML>你这个应该使用子查询 delete from 表名 where 供应商ID in (Selecte 供应商ID from 工程J2供应零件的供应商) 如果你怕出错,可以将开头的delete改为Selecte,先进行查询,然后再修改为delete进行删除即可。
赞
(0)
打赏
微信扫一扫
支付宝扫一扫
今天在网上抢购米4,还需要注册账号吗?
上一篇
2023-06-16
内存卡损坏了怎么办?
下一篇
2023-06-16
评论列表(0条)