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>
如果总结起来,应用有这几种方法:
1、直接输入:建立表后,直接向表中输入数据
2、导入外部数据:可以把外部数据,如电子表格、文本文件、其它数据库数据,导入到ACCESS表中。
以上就是关于如何 *** 作Access数据库(查询,删除,更新,增加)全部的内容,包括:如何 *** 作Access数据库(查询,删除,更新,增加)、access数据库表中输入数据的方法有几种、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)