<br />
<b>Warning</b>:  Undefined array key "HTTP_ACCEPT_LANGUAGE" in <b>/www/wwwroot/01xj.net/wp-content/plugins/wp-ue/main.php</b> on line <b>13</b><br />
{"id":286,"date":"2012-04-16T22:27:44","date_gmt":"2012-04-16T22:27:44","guid":{"rendered":"http:\/\/www.01xj.net\/0\/?p=286"},"modified":"2012-04-16T22:27:44","modified_gmt":"2012-04-16T22:27:44","slug":"vb-ado-%e6%93%8d%e4%bd%9caccess%e6%95%b0%e6%8d%ae%e5%ba%93%ef%bc%88%e5%88%9b%e5%bb%ba%ef%bc%8c%e6%b7%bb%e5%8a%a0%ef%bc%8c%e4%bf%ae%e6%94%b9%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.01xj.net\/?p=286","title":{"rendered":"Vb ADO \u64cd\u4f5cAccess\u6570\u636e\u5e93\uff08\u521b\u5efa\uff0c\u6dfb\u52a0\uff0c\u4fee\u6539\uff09"},"content":{"rendered":"<p><span style=\"font-family: Times New Roman;\">DAO(Data Access Object)<\/span>\u5168\u79f0\u4e3a\u6570\u636e\u8bbf\u95ee\u5bf9\u8c61\uff0c\u5b83\u662f\u6570\u636e\u5e93\u7f16\u7a0b\u7684\u91cd\u8981\u65b9\u6cd5\u4e4b\u4e00\u3002<span style=\"font-family: Times New Roman;\">DAO<\/span>\u7684\u4e00\u79cd\u9762\u5411\u5bf9\u8c61\u7684\u754c\u9762\u63a5\u53e3<span style=\"font-family: Times New Roman;\">,<\/span>\u7279\u8272\u4e3a\u5b83\u4e0d\u662f\u53ef\u89c6\u5316\u7684\u5bf9\u8c61\uff0c\u4f7f\u7528\u5b83\u5168\u90e8\u90fd\u8981\u9760\u7f16\u7801\u6765\u5b8c\u6210\uff0c<span style=\"font-family: Times New Roman;\">DAO<\/span>\u662f\u8bbe\u8ba1\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7cfb\u7edf\u7ed3\u6784\u7684\u5bf9\u8c61\u7c7b\u7684\u96c6\u5408\u3002\u5b83\u63d0\u4f9b\u4e86\u5b8c\u6210\u7ba1\u7406\u8fd9\u6837\u4e00\u4e2a\u7cfb\u7edf\u6240\u9700\u7684\u5168\u90e8\u64cd\u4f5c\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\uff0c\u5305\u62ec\u521b\u5efa\u6570\u636e\u5e93\uff0c\u5b9a\u4e49\u8868\u3001\u5b57\u6bb5\u548c\u7d22\u5f15\uff0c\u5efa\u7acb\u8868\u95f4\u7684\u5173\u7cfb\uff0c\u5b9a\u4f4d\u548c\u67e5\u8be2\u6570\u636e\u5e93\u7b49\u5de5\u5177\u3002\u7531\u4e8e<span style=\"font-family: Times New Roman;\">ADO(ActiveX Data Object ActiveX <\/span>\u6570\u636e\u5bf9\u8c61<span style=\"font-family: Times New Roman;\">)<\/span>\u7684\u51fa\u73b0\uff0c<span style=\"font-family: Times New Roman;\">DAO<\/span>\u7684\u4f7f\u7528\u5df2\u5927\u5927\u51cf\u5c11\uff0c\u4f46\u5b83\u65e0\u987b\u4f7f\u7528<span style=\"font-family: Times New Roman;\">ODBC(<\/span>\u5f00\u653e\u6570\u636e\u5e93\u8fde\u63a5<span style=\"font-family: Times New Roman;\">)<\/span>\u4fbf\u53ef\u8fde\u63a5\u5404\u4e2a\u6570\u636e\u6e90\uff0c\u56e0\u800c\u6211\u4eec\u4ecd\u7ecf\u5e38\u7528\u7ecf\u5178\u7684<span style=\"font-family: Times New Roman;\">DAO<\/span>\u3002\u4e0b\u9762\u6211\u5411\u5927\u5bb6\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528<span style=\"font-family: Times New Roman;\">DAO<\/span>\u7f16\u7a0b\u3002<span style=\"font-family: Times New Roman;\"><br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">DAO<\/span>\u4f7f\u7528\u4e4b\u524d\u5fc5\u987b\u5148\u5f15\u7528\u3002\u65b9\u6cd5\u4e3a\u6253\u5f00<span style=\"font-family: Times New Roman;\">VB6.0 , <\/span>\u4ece<span style=\"font-family: Times New Roman;\">VB<\/span>\u7684<span style=\"font-family: Times New Roman;\">&#8220;<\/span>\u5de5\u7a0b<span style=\"font-family: Times New Roman;\">&#8220;<\/span>\u83dc\u5355\u4e2d\uff0c\u9009\u62e9<span style=\"font-family: Times New Roman;\">&#8220;<\/span>\u5f15\u7528<span style=\"font-family: Times New Roman;\">&#8220;<\/span>\u9879\uff0c\u5f53<span style=\"font-family: Times New Roman;\">&#8220;<\/span>\u5f15\u7528<span style=\"font-family: Times New Roman;\">&#8220;<\/span>\u5bf9\u8bdd\u6846\u51fa\u73b0\u540e\uff0c\u4ece\u5e93\u7684\u5217\u8868\u4e2d\uff0c\u9009\u62e9<span style=\"font-family: Times New Roman;\">&#8220;Microsoft DAO 3.51 Object Library&#8221;,<\/span>\u5355\u51fb<span style=\"font-family: Times New Roman;\">&#8220;<\/span>\u786e\u5b9a<span style=\"font-family: Times New Roman;\">&#8220;<\/span>\u3002\u73b0\u5728\u4fbf\u53ef\u4ee5\u4f7f\u7528<span style=\"font-family: Times New Roman;\">DAO<\/span>\u5bf9\u8c61\u5e93\u63d0\u4f9b\u7684\u6240\u6709\u5bf9\u8c61\u8fdb\u884c\u7f16\u7a0b\u4e86\u3002<span style=\"font-family: Times New Roman;\"><br \/>\n<\/span>\u3000\u3000\u4e00\u3001\u521b\u5efa\u6570\u636e\u5e93\uff1a<span style=\"font-family: Times New Roman;\"><br \/>\n<\/span>\u3000\u3000\u5728<span style=\"font-family: Times New Roman;\">DAO<\/span>\u4e2d\u7528<span style=\"font-family: Times New Roman;\">CreatDataBase<\/span>\u65b9\u6cd5\u53ef\u4ee5\u6839\u636e\u7528\u6237\u9700\u6c42\u52a8\u6001\u7684\u521b\u5efa\u6570\u636e\u5e93\u3002\u8fd9\u4e00\u70b9\u5728\u7a0b\u5e8f\u4e2d\u662f\u975e\u5e38\u6709\u7528\u7684\u3002\u7528\u6237\u53ef\u4ee5\u6839\u636e\u8981\u6c42\u5b9e\u65f6\u5efa\u7acb\u6570\u636e\u5e93\u3002\u5efa\u7acb\u8fc7\u7a0b\u5982\u4e0b\uff1a\u3000\u3000<span style=\"font-family: Times New Roman;\"><br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Private Sub Com_creat_Click()<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">On Error GoTo Err100<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">CreatDataBase &#8220;<\/span>\u6570\u636e\u5e93\u540d\u79f0<span style=\"font-family: Times New Roman;\">.mdb&#8221; <\/span>\uff0c<span style=\"font-family: Times New Roman;\">dbLangGeneral<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Msgbox &#8220;<\/span>\u6570\u636e\u5e93\u5efa\u7acb\u5b8c\u6bd5<span style=\"font-family: Times New Roman;\">&#8221;<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Exit Sub<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Err100:<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">MsgBox &#8220;<\/span>\u4e0d\u80fd\u5efa\u7acb\u6570\u636e\u5e93<span style=\"font-family: Times New Roman;\">! &#8221; amp; vbCrLf amp; vbCrLf amp; Err.Description, vbInformation<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">End Sub<br \/>\n<\/span>\u3000\u3000\u8fd9\u6837\uff0c\u6570\u636e\u5e93\u4fbf\u5728\u5f53\u524d\u9ed8\u8ba4\u7684\u8def\u5f84\u4e0b\u5efa\u7acb\u4e86\u3002<span style=\"font-family: Times New Roman;\"><br \/>\n<\/span>\u3000\u3000\u4e8c\u3001\u521b\u5efa\u8868\u4e0e\u5b57\u6bb5\uff1a<span style=\"font-family: Times New Roman;\"><br \/>\n<\/span>\u3000\u3000\u5efa\u7acb\u6570\u636e\u5e93\u540e\uff0c\u5219\u9700\u8981\u5728\u8be5\u6570\u636e\u5e93\u4e2d\u5efa\u7acb\u8868\uff0c\u8fd9\u8981\u7528\u5230<span style=\"font-family: Times New Roman;\">TableDef <\/span>\u5bf9\u8c61\u3002\u5148\u5b9a\u4e49\u4e00\u4e2a<span style=\"font-family: Times New Roman;\">TableDef<\/span>\u7c7b\u578b\u7684\u5bf9\u8c61\uff0c\u7136\u540e\u7528<span style=\"font-family: Times New Roman;\">TableDef<\/span>\u96c6\u5408\u4e2d<span style=\"font-family: Times New Roman;\">Append<\/span>\u65b9\u6cd5\u5c06\u4e4b\u8ffd\u52a0\u5230\u6570\u636e\u5e93\u5f53\u4e2d\u53bb\u3002\u5e76\u4e14\u540c\u65f6\u5b9a\u4e49\u4e00\u4e2a<span style=\"font-family: Times New Roman;\">Field<\/span>\u5bf9\u8c61\uff0c\u7528<span style=\"font-family: Times New Roman;\">CreatFiele<\/span>\u7684\u65b9\u6cd5\u521b\u5efa\u4e00\u4e2a<span style=\"font-family: Times New Roman;\">Field<\/span>\u5bf9\u8c61\uff0c\u5411\u8868\u4e2d\u6dfb\u52a0\u5b57\u6bb5\u3002\u4f8b\u5982<span style=\"font-family: Times New Roman;\">:<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Private Sub Com_table_Click()<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">On Error GoTo Err100<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Dim Defdb As DataBase<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Dim NewTable As TableDef<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Dim NewField As Field<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Set Defdb = Workspaces(0).OpenDatabase (App.path amp; &#8220;\\<\/span>\u6570\u636e\u5e93\u540d\u79f0<span style=\"font-family: Times New Roman;\">.mdb&#8221; ,0, False)<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Set NewTable = DefDataBase.CreateTableDef(&#8220;<\/span>\u8868\u540d<span style=\"font-family: Times New Roman;\">&#8220;)<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Set NewField = DefTable.CreateField( &#8220;<\/span>\u5b57\u6bb5\u540d<span style=\"font-family: Times New Roman;\">&#8221; , dbText ,6) \u2032<\/span>\u521b\u5efa\u4e00\u4e2a\u5b57\u7b26\u578b\u7684\u5b57\u6bb5\uff0c\u957f\u5ea6\u4e3a<span style=\"font-family: Times New Roman;\">6<\/span>\u4e2a\u5b57\u7b26<span style=\"font-family: Times New Roman;\"><br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">DefTableFields.Append NewField \u2032<\/span>\u5b57\u6bb5\u8ffd\u52a0<span style=\"font-family: Times New Roman;\"><br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">DefDatabase.TableDefs.Append NewTable \u2032<\/span>\u8868\u8ffd\u52a0<span style=\"font-family: Times New Roman;\"><br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Msgbox &#8221; <\/span>\u8868\u5efa\u7acb\u5b8c\u6bd5<span style=\"font-family: Times New Roman;\"> &#8221;<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Exit Sub<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Err100:<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">MsgBox &#8220;<\/span>\u5bf9\u4e0d\u8d77\uff0c\u4e0d\u80fd\u5efa\u7acb\u8868\u3002\u8bf7\u5148\u518d\u5efa\u8868\u524d\u5efa\u7acb\u6570\u636e\u5e93\uff1f<span style=\"font-family: Times New Roman;\">&#8220;, vbCritical<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">End Sub<br \/>\n<\/span>\u3000\u3000\u4e00\u4e2a\u6570\u636e\u5e93\u53ef\u80fd\u6709\u5341\u51e0\u4e2a\u751a\u81f3\u51e0\u5341\u4e2a\u5b57\u6bb5\uff0c\u4e00\u4e2a\u8868\u4e2d\u6709\u591a\u5c11\u4e2a\u5b57\u6bb5\uff0c\u5219\u8981\u521b\u5efa\u591a\u5c11\u6b21\u5e76\u8981\u8ffd\u52a0\u5230\u8868\u4e2d\u3002\u6bcf\u5efa\u7acb\u4e00\u4e2a\u5b57\u6bb5\u540e\u90fd\u8981\u7528\u5230\u5b57\u6bb5\u8ffd\u52a0\u547d\u4ee4\uff0c\u4f46\u662f\u8868\u8ffd\u52a0\u53ea\u9700\u5728\u6240\u6709\u5b57\u6bb5\u5efa\u7acb\u5b8c\u6210\u540e\u7528\u4e00\u6761\u547d\u4ee4\u5373\u53ef\u5b8c\u6210\u3002<\/p>\n<p>\u3000\u3000\u4e09\u3001\u6253\u5f00\u6570\u636e\u5e93\uff1a<span style=\"font-family: Times New Roman;\"><br \/>\n<\/span>\u3000\u3000\u5728<span style=\"font-family: Times New Roman;\">VB<\/span>\u4e2d\uff0c\u5bf9\u4e00\u4e2a\u5bf9\u8c61\u53d8\u91cf\u5f15\u7528\u4e4b\u524d\u5fc5\u987b\u52a0\u4ee5\u8bf4\u660e\u3002<span style=\"font-family: Times New Roman;\">DAO<\/span>\u4e5f\u662f\u5982\u6b64\uff0c\u5fc5\u987b\u5148\u58f0\u660e\u6570\u636e\u5e93\u53d8\u91cf\uff0c\u4f8b\u5982\uff1a<span style=\"font-family: Times New Roman;\">Dim dbase As Database <\/span>\u3002\u5efa\u7acb\u4e86\u6570\u636e\u5e93\u5bf9\u8c61\u53d8\u91cf\u540e\uff0c\u6211\u4eec\u4fbf\u53ef\u6253\u5f00\u6570\u636e\u5e93\u4e86\uff0c\u5728\u4e00\u822c\u60c5\u51b5\u4e0b\u90fd\u53ea\u662f\u8bbf\u95ee\u4e00\u4e2a\u6570\u636e\u5e93\uff0c\u5f53\u6253\u5f00\u6570\u636e\u5e93\u540e\u518d\u5bf9\u6570\u636e\u5e93\u4e2d\u7684\u5404\u4e2a\u8bb0\u5f55\u8fdb\u884c\u64cd\u4f5c\uff0c\u8fd9\u5c31\u8981\u7528\u5230<span style=\"font-family: Times New Roman;\">Recordset <\/span>\u5bf9\u8c61\u5efa\u7acb\u8bb0\u5f55\u96c6\u3002\u4f8b\u5982\uff1a\u3000\u3000\u3000\u3000<\/p>\n<p><span style=\"font-family: Times New Roman;\">Private Sub Command_OpenDatabase_Click()<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Dim dbase as Database<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Dim rs As Recordset<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Set dbase = OpenDatabase ( App.path amp; &#8220;\\<\/span>\u6570\u636e\u5e93\u540d\u79f0<span style=\"font-family: Times New Roman;\">.mdb&#8221; )<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">Set rs = dbase.OpenRecordset ( &#8221; select * from <\/span>\u8868\u540d<span style=\"font-family: Times New Roman;\"> &#8221; )<br \/>\n<\/span>\u3000\u3000<span style=\"font-family: Times New Roman;\">End Sub<br \/>\n<\/span>\u3000\u3000\u8fd9\u6837\uff0c\u6570\u636e\u5e93\u4e2d\u7684\u8bb0\u5f55\u4fbf\u653e\u5230<span style=\"font-family: Times New Roman;\">Recordset<\/span>\u4e2d\uff0c\u53ef\u4ee5\u8fdb\u884c\u540e\u7eed\u64cd\u4f5c\u4e86\u3002<span style=\"font-family: Times New Roman;\"><br \/>\n<\/span>\u3000\u3000<\/p>\n<p>\u56db\u3001\u4f7f\u7528\u6570\u636e\u5e93\uff1a<span style=\"font-family: Times New Roman;\"><br \/>\n<\/span>\u3000\u3000\u5f53\u6253\u5f00\u6570\u636e\u5e93\uff0c\u5efa\u7acb<span style=\"font-family: Times New Roman;\">Recordset <\/span>\u8bb0\u5f55\u96c6\u540e\uff0c\u4fbf\u53ef\u6d4f\u89c8\u3001\u5220\u9664\u3001\u6dfb\u52a0\u3001\u67e5\u627e\u6570\u636e\u5e93\u4e2d\u7684\u5185\u5bb9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>DAO(Data Access Object)\u5168\u79f0\u4e3a\u6570\u636e\u8bbf\u95ee\u5bf9\u8c61\uff0c\u5b83&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-vb"],"_links":{"self":[{"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.01xj.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286"}],"version-history":[{"count":2,"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions"}],"predecessor-version":[{"id":288,"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions\/288"}],"wp:attachment":[{"href":"https:\/\/www.01xj.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.01xj.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.01xj.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}