access数据库中的 *** 作查询是在一个或多个数据表中检索更新指定。根据查询相关公开信息显示, *** 作查询是在一次查询 *** 作中对所得的结果进行编辑等 *** 作,才能在一个或多个数据表中检索更新指定。
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>
id=int(requestform("id"))
dim rs,rss
set rs=serverCreateObject("adodbrecordset")
rsOpen "select from news where id="&id,conn,1,3
rs("content")=trim(requestform("content"))
rsUpdate
rsClose
set rs=nothing
set rss=serverCreateObject("adodbrecordset")
rssOpen "select from article where id="&id,conn,1,3
rss("content")=trim(requestform("content"))
rssUpdate
rssClose
set rss=nothing
1首先使用Access创建一个数据保存在硬盘某处,使用MDB
2打开Vs 2013,引入命名空间:
using SystemDataOleDb;
声明对象:
private OleDbConnection _oleDbConn; private OleDbDataAdapter _oleDbAda;
3构建链接信息:
public readonly static string _strdata = stringFormat("{0}{1}{2}", "provider=microsoftjetoledb40; Data Source=", SystemIOPathGetDirectoryName(AssemblyGetExecutingAssembly()Location), @"\db\StuManDatamdb");
我这里是构建一个目录:当前目录先的db文件夹下的StuMandatamdb数据库文件。
当然你可以可以直接指定目录:例:
string_strdata=@"provider=microsoftjetoledb40; Data Source=C:\db\StuManDatamdb";
这样就构建好了链接信息。
4_oleDbConn = new OleDbConnection(_strConn);//根据链接信息实例化链接对象
_oleDbConnopen();//打开连接;
_oleDbAda = new OleDbDataAdapter(strsql, _oleDbConn);//strsql sql语句;
见过sql语句执行的数据库连接对象
_oleDbAdaFill(dt, tableName);
//将结果保存到本地结果及 dt==DataSet dt=new DataSet();
//Ok,Now,可以 *** 作dt了,当然前提它不是空的。
5调用示例,构建Sql语句,传给显示窗体对象。
6使用封装好的类,返回查询结果集,并提取数据。
7运行结果。
以上就是关于access数据库中的什么是在一个或多个数据表中检索更新指定全部的内容,包括:access数据库中的什么是在一个或多个数据表中检索更新指定、如何 *** 作Access数据库(查询,删除,更新,增加)、Access中两张表之间数据更新等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)