{"id":5897,"date":"2016-10-10T18:45:21","date_gmt":"2016-10-10T09:45:21","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=5897"},"modified":"2017-10-23T12:57:10","modified_gmt":"2017-10-23T03:57:10","slug":"databaseadobase","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/databaseadobase\/","title":{"rendered":"\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\uff08Access \u7b49\uff09\u306b\u63a5\u7d9a\uff08ADO\uff09"},"content":{"rendered":"<h2>ADO \u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a<\/h2>\n<div class=\"m30-l\">\n<p>\u5916\u90e8\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u64cd\u4f5c\u3059\u308b\u65b9\u6cd5\u306e\u3072\u3068\u3064\u306b <strong>ADO<\/strong>\uff08AcriveX Data Objects\uff09\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n    \u4f7f\u7528\u3059\u308b\u306b\u306f\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u53c2\u7167\u8a2d\u5b9a\u3092\u884c\u3046\u65b9\u6cd5\u3068\u3001<strong>CreateObject \u95a2\u6570<\/strong> \u3092\u4f7f\u3046\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<br \/>\n<h3>Connection \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30fbRecordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/h3>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <span class=\"red\"><strong>\uff1cCreateObject \u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\uff1e<\/strong><\/span><br \/>\n    <strong>Dim<\/strong> <em>cn<\/em> <strong>As Object<\/strong>\u3000\u3000\u3000\u2026\u2026\u3000Connection \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<br \/>\n    <strong>Dim<\/strong> <em>rs<\/em> <strong>As Object<\/strong>\u3000\u3000\u3000\u2026\u2026\u3000Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/p>\n<p>    <strong>Set<\/strong> <em>cn<\/em> = <strong>CreateObject<\/strong>(&#8220;ADODB.Connection&#8221;)<br \/>\n    <strong>Set<\/strong> <em>rs<\/em> = <strong>CreateObject<\/strong>(&#8220;ADODB.Recordset&#8221;)<\/p>\n<p>    <span class=\"red\"><strong>\uff1c\u53c2\u7167\u8a2d\u5b9a\u3092\u884c\u3046\u5834\u5408\uff1e<\/strong><\/span><br \/>\n    <strong>Dim<\/strong> <em>cn<\/em> <strong>As New<\/strong> ADODB.Connection\u3000\u3000\u3000\u2026\u2026\u3000Connection \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<br \/>\n    <strong>Dim<\/strong> <em>rs<\/em> <strong>As New<\/strong> ADODB.Recordset \u3000\u3000\u3000\u2026\u2026\u3000Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/p><\/div>\n<br \/>\n<h4>\u53c2\u7167\u8a2d\u5b9a\u3092\u884c\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u30d5\u30a1\u30a4\u30eb\u306b\u3064\u3044\u3066<\/h4>\n<div class=\"m30-l\">\n<p class=\"caution4\">Excel2003 \u4ee5\u524d\u3067\u306f\u3001<strong>Microsoft ActiveX Data Objects 2.8 Library<\/strong> \u3092\u9078\u629e\u3057\u307e\u3059\u3002<br \/>\n      Excel2007 \u4ee5\u964d\u3067\u306f\u3001<strong>Microsoft ActiveX Data Objects <em>\u30d0\u30fc\u30b8\u30e7\u30f3\u756a\u53f7<\/em> Library<\/strong> \u3092\u9078\u629e\u3057\u307e\u3059\u3002<br \/>\n      \u203b \u8907\u6570\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u3042\u308a\u307e\u3059\u3002\u7279\u306b\u5fc5\u8981\u304c\u306a\u3051\u308c\u3070\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u9078\u629e\u3059\u308b\u3068\u826f\u3044\u3067\u3057\u3087\u3046\u3002<br \/>\n      \u53c2\u7167\u8a2d\u5b9a\u306e\u65b9\u6cd5\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/excelwork.info\/excel\/filesystemobject\/\">\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff08FileSystemObject\uff09\u306e\u4f7f\u3044\u65b9<\/a> \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p class=\"caution4\"><strong>CreatObject \u95a2\u6570<\/strong> \u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u3001\u53c2\u7167\u8a2d\u5b9a\u306e\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001VBE \u3067\u3001\u81ea\u52d5\u30e1\u30f3\u30d0\u8868\u793a\u7b49\u306e\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u652f\u63f4\u6a5f\u80fd\u304c\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u3002\u307e\u305f\u3001\u30de\u30af\u30ed\u306e\u5b9f\u884c\u901f\u5ea6\u3082\u9045\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<br \/><\/div>\n<br \/>\n<h3>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u63a5\u7d9a\uff08Open \u30e1\u30bd\u30c3\u30c9\uff09<\/h3>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>.<strong>Open<\/strong>[ ( <em>ConnectionString<\/em>, <em>UserID<\/em>, <em>Password<\/em>, <em>Options<\/em> ) ]<\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>Connection \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>ConnectionString&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u63a5\u7d9a\u60c5\u5831\u3092\u542b\u3080\u6587\u5b57\u5217\u578b\uff08String\uff09\u306e\u5024\uff08\u300c\u5909\u6570\u540d=\u8a2d\u5b9a\u5024;\u300d)\u3092\u6307\u5b9a\u3057\u307e\u3059\uff08\u7701\u7565\u53ef\uff09\u3002<br \/>\n\t\u3010<strong>ConnectionString<\/strong> \u5185\u3067\u4f7f\u7528\u3059\u308b\u5909\u6570\u306b\u3064\u3044\u3066\u3011<br \/>\n\t\u25a0\u3000<strong>Provider<\/strong>\uff1a\u63a5\u7d9a\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u7a2e\u985e\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<div class=\"m30-l\">\n<table>\n<tr>\n<td align = \"center\" width=\"200\" bgcolor=\"#ffffccc\"><strong>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9<\/strong><\/td>\n<td align = \"center\" width=\"300\" bgcolor=\"#ffffccc\"><strong>\u8a2d\u5b9a\u3059\u308b\u6587\u5b57\u5217<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"200\">Access 2007<\/td>\n<td width=\"300\">Microsoft.ACE.OLEDB.12.0;<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">Access 2003 \u4ee5\u524d<\/td>\n<td width=\"300\">Microsoft.Jet.OLEDB.4.0;<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">Oracle<\/td>\n<td width=\"300\">MSDAORA;<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">SQLServer<\/td>\n<td width=\"300\">SQLOLEDB;<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">DB2<\/td>\n<td width=\"300\">IBMDADB2;<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">ODBC \u63a5\u7d9a<\/td>\n<td width=\"300\">MSDASQL;<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">Excel 2007<\/td>\n<td width=\"300\">Microsoft.ACE.OLEDB.12.0;<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">Excel 2003 \u4ee5\u524d<\/td>\n<td width=\"300\">Microsoft.Jet.OLEDB.4.0;<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">CSV \u30d5\u30a1\u30a4\u30eb<\/td>\n<td width=\"300\">Microsoft.Jet.OLEDB.4.0;<\/td>\n<\/tr>\n<\/table>\n<p>\n      <\/div>\n<p>\n\t\u25a0\u3000<strong>Data Source<\/strong>\uff1a\u63a5\u7d9a\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u5834\u6240\uff08\u30d1\u30b9\u30fb\u30d5\u30a1\u30a4\u30eb\u540d\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br \/>\n\t\u3000\u3000\u203b <strong>CSV \u30d5\u30a1\u30a4\u30eb<\/strong>\u306e\u5834\u5408\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u5b58\u5728\u3059\u308b\u30d1\u30b9\u306e\u307f\u3092\u6307\u5b9a\u3057\u307e\u3059\uff08\u6700\u5f8c\u306f\u3001<strong>\\<\/strong>\uff09\u3002<br \/>\n\t<br \/>\n\t\u25a0\u3000<strong>Extended Properties<\/strong>\uff1aExcel\u3084CSV\u30d5\u30a1\u30a4\u30eb\u306b\u63a5\u7d9a\u3059\u308b\u3068\u304d\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<div class=\"m30-l\">\n<table>\n<tr>\n<td align = \"center\" width=\"200\" bgcolor=\"#ffffccc\"><strong>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9<\/strong><\/td>\n<td align = \"center\" width=\"300\" bgcolor=\"#ffffccc\"><strong>\u8a2d\u5b9a\u3059\u308b\u6587\u5b57\u5217<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"200\">Excel 2007<\/td>\n<td width=\"300\">Excel 12.0;<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">Excel 2003 \u4ee5\u524d<\/td>\n<td width=\"300\">Excel 8.0;<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">CSV \u30d5\u30a1\u30a4\u30eb<\/td>\n<td width=\"300\">Text;<\/td>\n<\/tr>\n<\/table><\/div>\n<p>\n      <\/li>\n<li>UserID&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b\u3068\u304d\u306b\u4f7f\u7528\u3059\u308b\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u6307\u5b9a\u3057\u307e\u3059\uff08\u7701\u7565\u53ef\uff09\u3002<\/li>\n<li>Password&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b\u3068\u304d\u306b\u4f7f\u7528\u3059\u308b\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u6307\u5b9a\u3057\u307e\u3059\uff08\u7701\u7565\u53ef\uff09\u3002<\/li>\n<li>Options&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u3001\u63a5\u7d9a\u304c\u78ba\u7acb\u3055\u308c\u305f\u5f8c (\u540c\u671f) \u3068\u78ba\u7acb\u3055\u308c\u308b\u524d (\u975e\u540c\u671f) \u306e\u3044\u305a\u308c\u3067\u7d42\u4e86\u3059\u308b\u304b\u3092\u6c7a\u5b9a\u3059\u308b <strong>ConnectOptionEnum \u5024<\/strong>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br \/>\n<table>\n<tr>\n<td align = \"center\" width=\"200\" bgcolor=\"#ffffccc\"><strong>\u5b9a\u6570<\/strong><\/td>\n<td align = \"center\" width=\"50\" bgcolor=\"#ffffccc\"><strong>\u5024<\/strong><\/td>\n<td align = \"center\" width=\"400\" bgcolor=\"#ffffccc\"><strong>\u5185\u5bb9<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adAsyncConnect<\/td>\n<td width=\"50\" align = \"center\">16<\/td>\n<td width=\"400\">\u975e\u540c\u671f\u3067\u63a5\u7d9a\u3057\u307e\u3059\u3002ConnectComplete \u30a4\u30d9\u30f3\u30c8\u306f\u3001\u63a5\u7d9a\u53ef\u80fd\u304b\u3069\u3046\u304b\u3092\u6c7a\u5b9a\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adConnectUnspecified<\/td>\n<td width=\"50\" align = \"center\">-1<\/td>\n<td width=\"400\">\u65e2\u5b9a\u5024\u3067\u3059\u3002\u540c\u671f\u3067\u63a5\u7d9a\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<\/table>\n<p>\n      <\/li>\n<\/ul>\n<br \/><\/div>\n<br \/>\n<h3>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u53c2\u7167\u3059\u308b\uff08Open \u30e1\u30bd\u30c3\u30c9\uff09<\/h3>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>.<strong>Open<\/strong>[ ( <em>Source<\/em>, <em>ActiveConnection<\/em>, <em>CursorTypes<\/em>, <em>LockType<\/em>, <em>Options<\/em> ) ]<\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>Source&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30c6\u30fc\u30d6\u30eb\u540d\u3001\u30af\u30a8\u30ea\u3001SQL\u6587\u306a\u3069\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>ActiveConnection&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;<strong>Connection \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong> \u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>CursorTypes&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30ec\u30b3\u30fc\u30c9\u3092\u53c2\u7167\u3059\u308b\u30ab\u30fc\u30bd\u30eb\u306e\u7a2e\u985e\u3092 <strong>CursorTypeEnum \u30af\u30e9\u30b9<\/strong> \u306e\u5b9a\u6570\uff08\u307e\u305f\u306f\u305d\u306e\u5024\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br \/>\n<table>\n<tr>\n<td align = \"center\" width=\"200\" bgcolor=\"#ffffccc\"><strong>\u5b9a\u6570<\/strong><\/td>\n<td align = \"center\" width=\"50\" bgcolor=\"#ffffccc\"><strong>\u5024<\/strong><\/td>\n<td align = \"center\" width=\"400\" bgcolor=\"#ffffccc\"><strong>\u5185\u5bb9<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adOpenForwardOnly<\/td>\n<td width=\"50\" align = \"center\">0<\/td>\n<td width=\"400\">\u524d\u65b9\u5c02\u7528\u30ab\u30fc\u30bd\u30eb\u3002\u30ec\u30b3\u30fc\u30c9\u306e\u30b9\u30af\u30ed\u30fc\u30eb\u65b9\u5411\u304c\u524d\u65b9\u5411\u306b\u9650\u5b9a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u9664\u304d\u3001\u9759\u7684\u30ab\u30fc\u30bd\u30eb\u3068\u540c\u3058\u50cd\u304d\u3092\u3057\u307e\u3059\u3002\uff08\u65e2\u5b9a\u5024\uff09<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adOpenKeyset<\/td>\n<td width=\"50\" align = \"center\">1<\/td>\n<td width=\"400\">\u30ad\u30fc\u30bb\u30c3\u30c8\u30ab\u30fc\u30bd\u30eb\u3092\u4f7f\u3044\u307e\u3059\u3002\u307b\u304b\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u8ffd\u52a0\u3057\u305f\u30ec\u30b3\u30fc\u30c9\u306f\u8868\u793a\u3067\u304d\u306a\u3044\u70b9\u3092\u9664\u304d\u3001\u52d5\u7684\u30ab\u30fc\u30bd\u30eb\u3068\u540c\u3058\u304f\u3001\u81ea\u5206\u306e Recordset \u304b\u3089\u307b\u304b\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u524a\u9664\u3057\u305f\u30ec\u30b3\u30fc\u30c9\u306f\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093\u3002\u307b\u304b\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u5909\u66f4\u3057\u305f\u30c7\u30fc\u30bf\u306f\u8868\u793a\u3067\u304d\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adOpenDynamic<\/td>\n<td width=\"50\" align = \"center\">2<\/td>\n<td width=\"400\">\u52d5\u7684\u30ab\u30fc\u30bd\u30eb\u3092\u4f7f\u3044\u307e\u3059\u3002\u307b\u304b\u306e\u30e6\u30fc\u30b6\u30fc\u306b\u3088\u308b\u8ffd\u52a0\u3001\u5909\u66f4\u3001\u304a\u3088\u3073\u524a\u9664\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002\u30d7\u30ed\u30d0\u30a4\u30c0\u304c\u30d6\u30c3\u30af\u30de\u30fc\u30af\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u3092\u9664\u304d\u3001Recordset \u5185\u3067\u306e\u3059\u3079\u3066\u306e\u52d5\u4f5c\u3092\u8a31\u53ef\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adOpenStatic<\/td>\n<td width=\"50\" align = \"center\">3<\/td>\n<td width=\"400\">\u30ad\u30fc\u30bb\u30c3\u30c8\u30ab\u30fc\u30bd\u30eb\u3092\u958b\u304d\u307e\u3059\u3002\u30c7\u30fc\u30bf\u306e\u691c\u7d22\u307e\u305f\u306f\u30ec\u30dd\u30fc\u30c8\u306e\u4f5c\u6210\u306b\u4f7f\u7528\u3059\u308b\u305f\u3081\u306e\u3001\u30ec\u30b3\u30fc\u30c9\u306e\u9759\u7684\u30b3\u30d4\u30fc\u3067\u3059\u3002\u307b\u304b\u306e\u30e6\u30fc\u30b6\u30fc\u306b\u3088\u308b\u8ffd\u52a0\u3001\u5909\u66f4\u3001\u307e\u305f\u306f\u524a\u9664\u306f\u8868\u793a\u3055\u308c\u307e\u305b\u3093\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adOpenUnspecified<\/td>\n<td width=\"50\" align = \"center\">-1<\/td>\n<td width=\"400\">\u30ab\u30fc\u30bd\u30eb\u306e\u7a2e\u985e\u3092\u6307\u5b9a\u3057\u307e\u305b\u3093\u3002<\/td>\n<\/tr>\n<\/table>\n<p>\n      <\/li>\n<li>LockType&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u7701\u7565\u53ef\u80fd\u3067\u3059\u3002\u30d7\u30ed\u30d0\u30a4\u30c0\u304c Recordset \u3092\u958b\u304f\u3068\u304d\u306b\u4f7f\u3046\u30ed\u30c3\u30af\uff08\u540c\u6642\u4f5c\u7528\uff09\u306e\u7a2e\u985e\u3092 <strong>LockTypeEnum \u30af\u30e9\u30b9<\/strong> \u306e\u5b9a\u6570\uff08\u307e\u305f\u306f\u305d\u306e\u5024\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br \/>\n<table>\n<tr>\n<td align = \"center\" width=\"200\" bgcolor=\"#ffffccc\"><strong>\u5b9a\u6570<\/strong><\/td>\n<td align = \"center\" width=\"50\" bgcolor=\"#ffffccc\"><strong>\u5024<\/strong><\/td>\n<td align = \"center\" width=\"400\" bgcolor=\"#ffffccc\"><strong>\u5185\u5bb9<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adLockReadOnly<\/td>\n<td width=\"50\" align = \"center\">1<\/td>\n<td width=\"400\">\u8aad\u307f\u53d6\u308a\u5c02\u7528\u3002\u30c7\u30fc\u30bf\u306e\u5909\u66f4\u306f\u51fa\u6765\u307e\u305b\u3093\uff08\u65e2\u5b9a\u5024\uff09\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adLockPessimistic<\/td>\n<td width=\"50\" align = \"center\">2<\/td>\n<td width=\"400\">\u30ec\u30b3\u30fc\u30c9\u5358\u4f4d\u306e\u6392\u4ed6\u7684\u30ed\u30c3\u30af\u3002\u7de8\u96c6\u76f4\u5f8c\u306e\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u3067\u30ec\u30b3\u30fc\u30c9\u3092\u30ed\u30c3\u30af\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adLockOptimistic<\/td>\n<td width=\"50\" align = \"center\">3<\/td>\n<td width=\"400\">\u30ec\u30b3\u30fc\u30c9\u5358\u4f4d\u306e\u5171\u6709\u7684\u30ed\u30c3\u30af\u3002<strong>Update \u30e1\u30bd\u30c3\u30c9<\/strong> \u3092\u547c\u3073\u51fa\u3057\u305f\u5834\u5408\u306b\u306e\u307f\u3001\u30ec\u30b3\u30fc\u30c9\u3092\u30ed\u30c3\u30af\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adLockBatchOptimistic<\/td>\n<td width=\"50\" align = \"center\">4<\/td>\n<td width=\"400\">\u5171\u6709\u7684\u30d0\u30c3\u30c1\u66f4\u65b0\u3002\u30d0\u30c3\u30c1\u66f4\u65b0\u30e2\u30fc\u30c9\u306e\u5834\u5408\u306b\u306e\u307f\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adLockUnspecified<\/td>\n<td width=\"50\" align = \"center\">-1<\/td>\n<td width=\"400\">\u30ed\u30c3\u30af\u306e\u7a2e\u985e\u3092\u6307\u5b9a\u3057\u307e\u305b\u3093\u3002<\/td>\n<\/tr>\n<\/table>\n<p>\n      <\/li>\n<li>Options&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5f15\u6570 <em>Source<\/em> \u306b\u6307\u5b9a\u3057\u305f\u5185\u5bb9\u306e\u7a2e\u985e\u3092 <strong>CommandTypeEnum \u30af\u30e9\u30b9<\/strong> \u306e\u5b9a\u6570\uff08\u307e\u305f\u306f\u305d\u306e\u5024\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\uff08AND \u6f14\u7b97\u5b50\u3067\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u7528\u53ef\uff09\u3002<br \/>\n<table>\n<tr>\n<td align = \"center\" width=\"200\" bgcolor=\"#ffffccc\"><strong>\u5b9a\u6570<\/strong><\/td>\n<td align = \"center\" width=\"50\" bgcolor=\"#ffffccc\"><strong>\u5024<\/strong><\/td>\n<td align = \"center\" width=\"400\" bgcolor=\"#ffffccc\"><strong>\u5185\u5bb9<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adCmdText<\/td>\n<td width=\"50\" align = \"center\">1<\/td>\n<td width=\"400\">SQL \u6587<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adCmdTable<\/td>\n<td width=\"50\" align = \"center\">2<\/td>\n<td width=\"400\">\u30c6\u30fc\u30d6\u30eb\u540d<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adCmdStoredProc<\/td>\n<td width=\"50\" align = \"center\">4<\/td>\n<td width=\"400\">\u30b9\u30c8\u30a2\u30c9 \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u540d<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adCmdUnknown<\/td>\n<td width=\"50\" align = \"center\">8<\/td>\n<td width=\"400\">\u4e0d\u660e\uff08\u65e2\u5b9a\u5024\uff09<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adCmdFile<\/td>\n<td width=\"50\" align = \"center\">256<\/td>\n<td width=\"400\">\u6c38\u7d9a\u7684\u306b\u4fdd\u5b58\u3055\u308c\u305f Recordset \u306e\u30d5\u30a1\u30a4\u30eb\u540d<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adCmdTableDirect<\/td>\n<td width=\"50\" align = \"center\">512<\/td>\n<td width=\"400\">\u5217\u304c\u3059\u3079\u3066\u8fd4\u3055\u308c\u308b\u30c6\u30fc\u30d6\u30eb\u540d<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adCmdUnspecified<\/td>\n<td width=\"50\" align = \"center\">-1<\/td>\n<td width=\"400\">\u30b3\u30de\u30f3\u30c9\u30bf\u30a4\u30d7\u5f15\u6570\u3092\u6307\u5b9a\u3057\u307e\u305b\u3093<\/td>\n<\/tr>\n<\/table>\n<p>\n      <\/li>\n<\/ul>\n<br \/><\/div>\n<\/div>\n<br \/><br \/>\n<h2>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\uff08Access\uff09\u3078\u63a5\u7d9a\u3059\u308b\u4f8b<\/h2>\n<div class=\"m30-l\">\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9 \u305d\u306e\uff11<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"Access \u3078\u63a5\u7d9a\uff08\u53c2\u7167\u8a2d\u5b9a\uff09\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_ADO_Access1()\r\n    \r\n    '\u53c2\u7167\u8a2d\u5b9a\r\n    'Microsoft ActiveX Data Objects 6.1 Library\r\n\r\n    Dim cn As New ADODB.Connection\r\n    Dim rs As New ADODB.Recordset\r\n    Dim ConStr As String\r\n    Dim DBFile As String\r\n    Dim strSQL As String\r\n    Dim FieldArray\r\n    Dim i As Long\r\n    Dim j As Long\r\n    Dim v As Variant\r\n    \r\n    ReDim FieldArray(1 To 1)\r\n        \r\n    DBFile = ActiveWorkbook.Path & \"\\mydb1.accdb\"\r\n    ConStr = \"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\" & DBFile     'Access 2007 \u4ee5\u964d\r\n    'ConStr = \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & DBFile     'Access 2003 \u4ee5\u524d\r\n    \r\n    cn.ConnectionString = ConStr\r\n    cn.Open\r\n    \r\n    strSQL = \"Select * from \u793e\u54e1\u540d\u7c3f order by ID desc;\"\r\n    rs.Source = strSQL\r\n    rs.ActiveConnection = cn\r\n    rs.Open\r\n\r\n    With Worksheets(\"Sheet1\")\r\n        \r\n        .Cells.Clear\r\n        \r\n        i = 1\r\n        Do Until rs.EOF\r\n            For j = 0 To rs.Fields.Count - 1\r\n                .Cells(i, j + 1) = rs(j).Value\r\n            Next j\r\n            rs.movenext\r\n            i = i + 1\r\n        Loop\r\n    \r\n    End With\r\n    \r\n    rs.Close\r\n    Set rs = Nothing\r\n    \r\n    cn.Close\r\n    Set cn = Nothing\r\n    \r\nEnd Sub\r\n\u3000\r\n  <\/pre>\n<br \/>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><a href=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2016\/10\/databaseadobase_access_01.jpg?ssl=1\" rel=\"lightbox[5897]\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2016\/10\/databaseadobase_access_01.jpg?resize=556%2C290&#038;ssl=1\" alt=\"ADO Access \uff08\u53c2\u7167\u8a2d\u5b9a\uff09\" width=\"556\" height=\"290\" class=\"alignnone size-full wp-image-5903\" srcset=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2016\/10\/databaseadobase_access_01.jpg?w=556&amp;ssl=1 556w, https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2016\/10\/databaseadobase_access_01.jpg?resize=400%2C209&amp;ssl=1 400w\" sizes=\"(max-width: 556px) 100vw, 556px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<\/div>\n<br \/><br \/>\n<h2>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\uff08Access\uff09\u3078\u63a5\u7d9a\u3059\u308b\u4f8b\uff08CreateObject \u95a2\u6570\u3092\u4f7f\u7528\uff09<\/h2>\n<div class=\"m30-l\">\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9 \u305d\u306e\uff12<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"Access\u3078\u63a5\u7d9a\uff08CreateObject\u95a2\u6570\uff09\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_ADO_Access2()\r\n    \r\n    'CreateObject \u95a2\u6570\r\n\r\n    Dim cn As Object\r\n    Dim rs As Object\r\n    Dim ConStr As String\r\n    Dim DBFile As String\r\n    Dim strSQL As String\r\n    Dim FieldArray\r\n    Dim i As Long\r\n    Dim j As Long\r\n    Dim v As Variant\r\n    \r\n    ReDim FieldArray(1 To 1)\r\n    \r\n    Set cn = CreateObject(\"ADODB.Connection\")\r\n    Set rs = CreateObject(\"ADODB.Recordset\")\r\n    \r\n    DBFile = ActiveWorkbook.Path & \"\\mydb1.accdb\"\r\n    ConStr = \"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\" & DBFile      'Access 2007 \u4ee5\u964d\r\n    'ConStr = \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & DBFile      'Access 2003 \u4ee5\u524d\r\n    \r\n    cn.Open ConnectionString:=ConStr & \";\"\r\n    \r\n    strSQL = \"Select * from \u793e\u54e1\u540d\u7c3f;\"\r\n\r\n    rs.Open strSQL, cn\r\n    \r\n    '\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\u53d6\u5f97\r\n    j = 1\r\n    For Each v In rs.Fields\r\n        \r\n        ReDim Preserve FieldArray(1 To j)\r\n        FieldArray(j) = v.Name\r\n        j = j + 1\r\n    \r\n    Next\r\n\r\n    'Sheet1 \u306b\u8868\u793a\r\n    With Worksheets(\"Sheet1\")\r\n        \r\n        .Cells.Clear\r\n        \r\n        '\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\r\n        .Range(.Cells(1, 1), .Cells(1, UBound(FieldArray))) = FieldArray\r\n        \r\n        '\u30ec\u30b3\u30fc\u30c9\r\n        .Range(\"A2\").CopyFromRecordset rs\r\n    \r\n    End With\r\n    \r\nDBEnd:\r\n    rs.Close\r\n    Set rs = Nothing\r\n    \r\n    cn.Close\r\n    Set cn = Nothing\r\n\r\nEnd Sub\r\n\u3000\r\n  <\/pre>\n<br \/>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><a href=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2016\/10\/databaseadobase_access_02.jpg?ssl=1\" rel=\"lightbox[5897]\"><img loading=\"lazy\" src=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2016\/10\/databaseadobase_access_02.jpg?resize=555%2C290&#038;ssl=1\" alt=\"ADO Access \uff08CreateObject \u95a2\u6570\uff09\" width=\"555\" height=\"290\" class=\"alignnone size-full wp-image-5904\" srcset=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2016\/10\/databaseadobase_access_02.jpg?w=555&amp;ssl=1 555w, https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2016\/10\/databaseadobase_access_02.jpg?resize=400%2C209&amp;ssl=1 400w\" sizes=\"(max-width: 555px) 100vw, 555px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<\/div>\n<br \/><br \/>\n","protected":false},"excerpt":{"rendered":"<p>ADO \u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a \u5916\u90e8\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u64cd\u4f5c\u3059\u308b\u65b9\u6cd5\u306e\u3072\u3068\u3064\u306b ADO &#8230; <\/p>\n","protected":false},"author":1,"featured_media":5903,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":""},"categories":[948],"tags":[953,950,721,952,951,814,38,949,835],"jetpack_featured_media_url":"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2016\/10\/databaseadobase_access_01.jpg?fit=556%2C290&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4Ye9i-1x7","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/5897"}],"collection":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/comments?post=5897"}],"version-history":[{"count":10,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/5897\/revisions"}],"predecessor-version":[{"id":6485,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/5897\/revisions\/6485"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/5903"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=5897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=5897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=5897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}