{"id":123,"date":"2012-03-16T04:03:07","date_gmt":"2012-03-16T04:03:07","guid":{"rendered":"http:\/\/mio-web.net\/pcsupport\/?p=123"},"modified":"2015-01-08T04:04:11","modified_gmt":"2015-01-08T04:04:11","slug":"odbc%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%82%bd%e3%83%bc%e3%82%b9%e3%82%92%e3%80%81vba%e3%81%ae%e3%82%b3%e3%83%bc%e3%83%89%e3%81%a7%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/mio-web.net\/pcsupport\/archives\/123\/","title":{"rendered":"ODBC\u306e\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u3092\u3001VBA\u306e\u30b3\u30fc\u30c9\u3067\u4f5c\u6210\u3059\u308b"},"content":{"rendered":"<p>http:\/\/www.accessclub.jp\/bbs5\/0020\/vba5763.html<br \/>\nhttp:\/\/support.microsoft.com\/kb\/287668\/JA\/<br \/>\n\u6b21\u306e\u4f8b\u3067\u306f\u3001SQLConfigDataSource \u306e API \u547c\u3073\u51fa\u3057\u3092\u4f7f\u7528\u3057\u3066\u30b7\u30b9\u30c6\u30e0 DSN \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u3053\u306e\u4f8b\u3067\u306f\u3001C:\\Northwind.mdb \u306b\u3042\u308b\u30b5\u30f3\u30d7\u30eb \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9 Northwind.mdb \u306e\u30c7\u30fc\u30bf \u30bd\u30fc\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u30b5\u30f3\u30d7\u30eb \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9 Northwind.mdb \u3092 C \u30c9\u30e9\u30a4\u30d6\u306e\u30eb\u30fc\u30c8 \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002<br \/>\n\u65b0\u3057\u3044 Access \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f5c\u6210\u3057\u3001Declarations \u30bb\u30af\u30b7\u30e7\u30f3\u306b\u6b21\u306e\u884c\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<p>Option Explicit<br \/>\nConst ODBC_ADD_SYS_DSN = 4 &#8216;Add data source<br \/>\nConst ODBC_CONFIG_SYS_DSN = 5 &#8216;Configure (edit) data source<br \/>\nConst ODBC_REMOVE_SYS_DSN = 6 &#8216;Remove data source<\/p>\n<p>Private Declare Function SQLConfigDataSource Lib &#8220;ODBCCP32.DLL&#8221; (ByVal _<br \/>\nhwndParent As Long, ByVal fRequest As Long, ByVal _<br \/>\nlpszDriver As String, ByVal lpszAttributes As String) As Long<\/p>\n<p>\u6b21\u306e\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<p>Function Build_SystemDSN(DSN_NAME As String, Db_Path As String)<\/p>\n<p>Dim ret%, Driver$, Attributes$<\/p>\n<p>Driver = &#8220;Microsoft Access Driver (*.MDB)&#8221; &amp; Chr(0)<br \/>\nAttributes = &#8220;DSN=&#8221; &amp; DSN_NAME &amp; Chr(0)<br \/>\nAttributes = Attributes &amp; &#8220;Uid=Admin&#8221; &amp; Chr(0) &amp; &#8220;pwd=&#8221; &amp; Chr(0)<br \/>\nAttributes = Attributes &amp; &#8220;DBQ=&#8221; &amp; Db_Path &amp; Chr(0)<\/p>\n<p>ret = SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, Driver, Attributes)<\/p>\n<p>&#8216;ret is equal to 1 on success and 0 if there is an error<br \/>\nIf ret &lt;&gt; 1 Then<br \/>\nMsgBox &#8220;DSN Creation Failed&#8221;<br \/>\nEnd If<\/p>\n<p>End Function<\/p>\n<p>\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8 \u30a6\u30a3\u30f3\u30c9\u30a6\u306b\u6b21\u306e\u884c\u3092\u5165\u529b\u3057 Enter \u30ad\u30fc\u3092\u62bc\u3057\u307e\u3059\u3002<br \/>\n? Build_SystemDSN(&#8220;My SampleDSN&#8221;,&#8221;c:\\Northwind.mdb&#8221;)<br \/>\n[\u30b9\u30bf\u30fc\u30c8] \u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3001[\u8a2d\u5b9a] \u3092\u30dd\u30a4\u30f3\u30c8\u3057\u3001[\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb \u30d1\u30cd\u30eb] \u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<br \/>\n\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb \u30d1\u30cd\u30eb\u3067\u3001[ODBC \u30c7\u30fc\u30bf \u30bd\u30fc\u30b9]\u3001[ODBC \u30c7\u30fc\u30bf \u30bd\u30fc\u30b9 (32 \u30d3\u30c3\u30c8)]\u3001\u307e\u305f\u306f [32 \u30d3\u30c3\u30c8 ODBC] \u3092\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<br \/>\n[\u30b7\u30b9\u30c6\u30e0 DSN] \u30bf\u30d6\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002[\u30b7\u30b9\u30c6\u30e0 \u30c7\u30fc\u30bf \u30bd\u30fc\u30b9] \u30dc\u30c3\u30af\u30b9\u306e\u4e00\u89a7\u306b My SampleDSN \u304c\u8ffd\u52a0\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/www.accessclub.jp\/bbs5\/0020\/vba5763.html http:\/\/support.microsoft.com\/kb\/287668\/JA\/ \u6b21\u306e\u4f8b\u3067\u306f\u3001SQLConfigData [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"vkexunit_cta_each_option":"","footnotes":""},"categories":[23],"tags":[],"class_list":["post-123","post","type-post","status-publish","format-standard","hentry","category-sqlserver"],"_links":{"self":[{"href":"https:\/\/mio-web.net\/pcsupport\/wp-json\/wp\/v2\/posts\/123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mio-web.net\/pcsupport\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mio-web.net\/pcsupport\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mio-web.net\/pcsupport\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mio-web.net\/pcsupport\/wp-json\/wp\/v2\/comments?post=123"}],"version-history":[{"count":1,"href":"https:\/\/mio-web.net\/pcsupport\/wp-json\/wp\/v2\/posts\/123\/revisions"}],"predecessor-version":[{"id":124,"href":"https:\/\/mio-web.net\/pcsupport\/wp-json\/wp\/v2\/posts\/123\/revisions\/124"}],"wp:attachment":[{"href":"https:\/\/mio-web.net\/pcsupport\/wp-json\/wp\/v2\/media?parent=123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mio-web.net\/pcsupport\/wp-json\/wp\/v2\/categories?post=123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mio-web.net\/pcsupport\/wp-json\/wp\/v2\/tags?post=123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}