{"id":663,"date":"2011-05-21T05:15:02","date_gmt":"2011-05-20T21:15:02","guid":{"rendered":"http:\/\/115.29.108.60\/?p=663"},"modified":"2011-09-26T21:55:49","modified_gmt":"2011-09-26T13:55:49","slug":"mfc-odbc%e4%b8%8eaccess","status":"publish","type":"post","link":"http:\/\/115.29.108.60\/?p=663","title":{"rendered":"MFC ODBC\u4e0eAccess"},"content":{"rendered":"<p>\u4eca\u5929\u5e2e\u4eba\u8c03\u8bd5\u7a0b\u5e8f\uff0c\u9047\u5230\u4e86MFC ODBC\u4e0eAccess\u6570\u636e\u5e93\u76f8\u5173\u7684\u95ee\u9898\uff0c\u8bb0\u5f55\u4e0b\u3002<\/p>\n<p>\u4e4b\u524d\u4ece\u672a\u771f\u6b63\u4f7f\u7528\u8fc7ODBC\u4e0eAccess\u6570\u636e\u5e93\uff0c\u4e0b\u9762\u662f\u4e00\u70b9\u7406\u89e3\uff1aODBC\u548cJDBC\u4e00\u6837\uff0c\u662f\u4e00\u5c42\u7edf\u4e00\u7684\u5c01\u88c5\uff0c\u7531\u5404\u4e2a\u6570\u636e\u5e93\u5382\u5546\u63d0\u4f9b\u7edf\u4e00\u7684\u63a5\u53e3\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528ODBC\u7684\u7edf\u4e00\u63a5\u53e3\uff0c\u56e0\u4e3a\u5b83\u5177\u6709\u901a\u7528\u6027\uff0c\u7a0d\u52a0\u4fee\u6539\u5c31\u80fd\u79fb\u690d\u5230\u4e0d\u540c\u6570\u636e\u5e93\u3002\u5f53\u7136\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6570\u636e\u5e93\u5382\u5546\u63d0\u4f9b\u7684\u5355\u72ec\u7684\u5e93\u3002<\/p>\n<p>\u4e0eAccess\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u672c\u8d28\u662f\u4e0e\u5176\u6570\u636e\u5e93\u6587\u4ef6\u6253\u4ea4\u9053\uff0c\u683c\u5f0f\u4e3a.mdb\u3002\u53ef\u4ee5\u901a\u8fc7COM\u6216\u8005MFC\u672c\u8eab\u7684ODBC\u652f\u6301\u6765\u5b9e\u73b0\u8fde\u63a5\u3002<\/p>\n<p>COM\u5b9e\u73b0\u8fde\u63a5\uff1a<a href=\"http:\/\/6520874.blog.163.com\/blog\/static\/7258271920113845626128\/\" target=\"_blank\">http:\/\/6520874.blog.163.com\/blog\/static\/7258271920113845626128\/<\/a><\/p>\n<p>MFC\u9879\u76ee\u5411\u5bfc\u4e2d\u6709\u5bf9ODBC\u7684\u652f\u6301\uff0c\u9996\u5148\u8981\u5728\u63a7\u5236\u9762\u677f&#8212;&gt;\u7ba1\u7406\u5de5\u5177\u4e2d\u914d\u7f6e\u6570\u636e\u6e90(ODBC)\u3002<\/p>\n<p>\u914d\u7f6e\u65f6\u6709\u4e09\u79cdDSN\uff08Data Source Name\uff0c\u6570\u636e\u6e90\u540d\u79f0\uff09\uff0c\u9700\u8981\u6839\u636e\u5177\u4f53\u60c5\u51b5\u53ca\u5176\u63d0\u793a\u8fdb\u884c\u914d\u7f6e\uff0c\u6dfb\u52a0Microsoft Access Driver\u76f8\u5173\u7684\u6570\u636e\u5e93.mdb\u6587\u4ef6\u3002<\/p>\n<p>MFC\u9879\u76ee\u5411\u5bfc\u4f1a\u81ea\u52a8\u751f\u6210\u76f8\u5173\u7684CxxxSet\u7c7b\u5bf9ODBC\u8fdb\u884c\u652f\u6301\u3002<\/p>\n<p>\u5728\u8fd9\u91cc\u6709\u8da3\u7684\u662f\uff0cVC6.0\u7684\u5bf9\u8bdd\u6846\u7f16\u8f91\u5668\u4e2d\u63d0\u4f9b\u4e86\u76f8\u5e94\u7684ActiveX\u63a7\u4ef6ADODC\u548cDATAGRID\u5bf9ODBC\u8fdb\u884c\u4e86\u89c6\u56fe\u652f\u6301\uff0c\u4f46VS2005\u4e2d\u786e\u6ca1\u6709\u3002\u5177\u4f53\u7684\u89e3\u51b3\u65b9\u6848\u662f\uff1a<a href=\"http:\/\/zhidao.baidu.com\/question\/210849183.html\" target=\"_blank\">http:\/\/zhidao.baidu.com\/question\/210849183.html<\/a><\/p>\n<p>\u5728\u8c03\u8bd5\u7684\u8fc7\u7a0b\u4e2d\uff0c\u56e0\u4e3a\u9879\u76ee\u7684\u5177\u4f53\u8981\u6c42\uff0c\u8fd8\u9047\u5230\u4e86\u4e00\u70b9\u95ee\u9898\u3002\u8be5\u9879\u76ee\u7684\u4e3b\u7a97\u53e3\u5373m_pMainWnd\u662f\u542b\u6709\u4ee5\u4e0a\u4e24\u4e2a\u63a7\u4ef6\u7684View\uff0c\u4e0d\u662fDlg\u3002\u73b0\u5728\u9700\u8981\u5148\u6709\u767b\u5f55\u5bf9\u8bdd\u6846\u8fdb\u884c\u767b\u5f55\u540e\u624d\u80fd\u51fa\u73b0\u4e3b\u7a97\u53e3\u3002<\/p>\n<p>\u5728InitInstance\u4e2d\u8fdb\u884c\u4fee\u6539\u5982\u4e0b\uff1a<br \/>\n\/\/ The one and only window has been initialized, so show and update it.<br \/>\n\/\/m_pMainWnd-&gt;ShowWindow(SW_SHOW);<br \/>\n\/\/m_pMainWnd-&gt;UpdateWindow();<br \/>\nCLoginDlg dlg;<br \/>\ndlg.DoModal();<br \/>\nreturn TRUE;<\/p>\n<p>\u7136\u540e\u5728\u767b\u5f55\u5bf9\u8bdd\u6846\u7684\u767b\u5f55\u6210\u529f\u5904\u6709\u5982\u4e0b\u4ee3\u7801\uff1a<br \/>\nAfxGetApp()-&gt;m_pMainWnd-&gt;ShowWindow(SW_SHOW);<br \/>\nAfxGetApp()-&gt;m_pMainWnd-&gt;UpdateWindow();<br \/>\nCDialog::OnOK();<\/p>\n<p>\u7ed3\u679c\u53d1\u73b0\u4e3b\u7a97\u53e3\u4f9d\u7136\u51fa\u73b0\uff0c\u5e76\u4e14CLoginDlg\u7684\u6784\u9020\u51fd\u6570\u4e2dAfxOleInit\u5904\u51fa\u73b0\u65ad\u8a00\u9519\u8bef\u3002\u6ce8\u91ca\u6389\u540e\uff0c\u65ad\u8a00\u9519\u8bef\u6d88\u5931\u3002<\/p>\n<p>\u4e8e\u662f\u6ce8\u91ca\u6389InitInstance\u4e2d\u5982\u4e0b\u4ee3\u7801\uff1a<br \/>\n\/\/\/\/ Parse command line for standard shell commands, DDE, file open<br \/>\n\/\/CCommandLineInfo cmdInfo;<br \/>\n\/\/ParseCommandLine(cmdInfo);<\/p>\n<p>\/\/\/\/ Dispatch commands specified on the command line<br \/>\n\/\/if (!ProcessShellCommand(cmdInfo))<br \/>\n\/\/ return FALSE;<\/p>\n<p>\u7ed3\u679c\u53d1\u73b0\u4f1a\u5728ShowWindow(SW_SHOW)\u5904\u51fa\u73b0\u65ad\u8a00\u9519\u8bef\uff0c\u5177\u4f53\u51fa\u73b0\u5728winocc.cpp ShowWindow\u4e2d\u7684ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));\u5904\u3002<\/p>\n<p>\u7ecf\u8fc7\u8c03\u8bd5\u53d1\u73b0m_pMainWnd\u4e3aNULL\u3002\u4e5f\u5c31\u662f\u8bf4\u5728ProcessShellCommand\u540em_pMainWnd\u624d\u4f1a\u6709\u6b63\u786e\u7684\u8d4b\u503c\u3002\u53c2\u8003\uff1a<a href=\"http:\/\/apps.hi.baidu.com\/share\/detail\/15714628\" target=\"_blank\">http:\/\/apps.hi.baidu.com\/share\/detail\/15714628<\/a><\/p>\n<p>\u6700\u7ec8\u89e3\u51b3\u65b9\u6848\uff1a\u76f8\u5173\u51fd\u6570\u7684\u8c03\u7528\u5ef6\u8fdf\u5230CLoginDlg\u7684\u767b\u5f55\u5904\u7406\u51fd\u6570\u4e2d\uff0c\u5982\u4e0b\uff1a<br \/>\n\/\/ Parse command line for standard shell commands, DDE, file open<br \/>\nCCommandLineInfo cmdInfo;<br \/>\nAfxGetApp()-&gt;ParseCommandLine(cmdInfo);<\/p>\n<p>\/\/ Dispatch commands specified on the command line<br \/>\nif (!AfxGetApp()-&gt;ProcessShellCommand(cmdInfo))<br \/>\nreturn ;<\/p>\n<p>\/\/ The one and only window has been initialized, so show and update it.<br \/>\nAfxGetApp()-&gt;m_pMainWnd-&gt;ShowWindow(SW_SHOW);<br \/>\nAfxGetApp()-&gt;m_pMainWnd-&gt;UpdateWindow();<br \/>\nCDialog::OnOK();<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u5e2e\u4eba\u8c03\u8bd5\u7a0b\u5e8f\uff0c\u9047\u5230\u4e86MFC ODBC\u4e0eAccess\u6570\u636e\u5e93\u76f8\u5173\u7684\u95ee\u9898\uff0c\u8bb0\u5f55\u4e0b\u3002 \u4e4b\u524d\u4ece\u672a\u771f\u6b63\u4f7f\u7528\u8fc7ODBC\u4e0e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-663","post","type-post","status-publish","format-standard","hentry","category-windows"],"_links":{"self":[{"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/posts\/663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/115.29.108.60\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=663"}],"version-history":[{"count":2,"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/posts\/663\/revisions"}],"predecessor-version":[{"id":933,"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/posts\/663\/revisions\/933"}],"wp:attachment":[{"href":"http:\/\/115.29.108.60\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/115.29.108.60\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=663"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/115.29.108.60\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}