{"id":6072,"date":"2017-09-04T08:49:20","date_gmt":"2017-09-03T23:49:20","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=6072"},"modified":"2017-09-04T08:49:20","modified_gmt":"2017-09-03T23:49:20","slug":"adorecordcount","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/adorecordcount\/","title":{"rendered":"Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5185\u306e\u30ec\u30b3\u30fc\u30c9\u6570\uff08ADO\uff09RecordCount \u30d7\u30ed\u30d1\u30c6\u30a3"},"content":{"rendered":"<h2>RecordCount \u30d7\u30ed\u30d1\u30c6\u30a3<\/h2>\n<div class=\"m30-l\">\n<p><strong>Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong>\u306e\u30ec\u30b3\u30fc\u30c9\u6570\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <span class=\"red\"><strong>\uff1c\u53d6\u5f97\uff1e<\/strong><\/span><br \/>\n    <em>long<\/em> = <em>object<\/em>.<strong>RecordCount<\/strong><\/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>long&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;<strong>Recordset<\/strong> \u306e\u30ec\u30b3\u30fc\u30c9\u6570\u3092\u793a\u3059\u9577\u6574\u6570\u578b\uff08long\uff09\u306e\u5024\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u30ec\u30b3\u30fc\u30c9\u6570\u304c\u308f\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30d7\u30ed\u30d0\u30a4\u30c0\u3084\u30ab\u30fc\u30bd\u30eb\u30bf\u30a4\u30d7\u304c <strong>RecordCount<\/strong> \u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001<strong>-1<\/strong> \u3092\u8fd4\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<br \/>\n<p class=\"caution4\">\u9589\u3058\u3066\u3044\u308b <strong>Recordset<\/strong> \u4e0a\u3067 <strong>RecordCount \u30d7\u30ed\u30d1\u30c6\u30a3<\/strong> \u3092\u53d6\u5f97\u3059\u308b\u3068\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n<p class=\"caution4\"><strong>Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong>\u306e\u30ab\u30fc\u30bd\u30eb\u30bf\u30a4\u30d7\u5225\u306e <strong>RecordCount \u30d7\u30ed\u30d1\u30c6\u30a3<\/strong> \u306e\u623b\u308a\u5024<\/p>\n<div class=\"m30-l\">\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011\u3000<\/strong><em>object<\/em>.<strong>CursorType<\/strong> = \uff1c\u30ab\u30fc\u30bd\u30eb\u30bf\u30a4\u30d7\uff1e<\/div>\n<p>\t\u203b\u3000<em>object<\/em>\u3000\u2026\u3000<strong>Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><br \/>\n\t<\/p>\n<table>\n<tr>\n<td align = \"center\" width=\"250\" bgcolor=\"#ffffccc\"><strong>\u30ab\u30fc\u30bd\u30eb\u30bf\u30a4\u30d7<\/strong><\/td>\n<td align = \"center\" width=\"250\" bgcolor=\"#ffffccc\"><strong>\u5185\u5bb9<\/strong><\/td>\n<td align = \"center\" width=\"150\" bgcolor=\"#ffffccc\"><strong>\u623b\u308a\u5024<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"250\">adOpenDynamic<\/td>\n<td width=\"250\">\u52d5\u7684\u30ab\u30fc\u30bd\u30eb<\/td>\n<td width=\"150\" align = \"center\">-1<\/td>\n<\/tr>\n<tr>\n<td width=\"250\">adOpenForwardOnly<\/td>\n<td width=\"250\">\u524d\u65b9\u30b9\u30af\u30ed\u30fc\u30eb\u30ab\u30fc\u30bd\u30eb<\/td>\n<td width=\"150\" align = \"center\">-1<\/td>\n<\/tr>\n<tr>\n<td width=\"250\">adOpenKeyset<\/td>\n<td width=\"250\">\u30ad\u30fc\u30bb\u30c3\u30c8\u30ab\u30fc\u30bd\u30eb<\/td>\n<td width=\"150\" align = \"center\">\u30ec\u30b3\u30fc\u30c9\u6570<\/td>\n<\/tr>\n<tr>\n<td width=\"250\">adOpenStatic<\/td>\n<td width=\"250\">\u9759\u7684\u30ab\u30fc\u30bd\u30eb<\/td>\n<td width=\"150\" align = \"center\">\u30ec\u30b3\u30fc\u30c9\u6570<\/td>\n<\/tr>\n<\/table>\n<p>\n      <\/div>\n<\/p>\n<p class=\"caution4\"><strong>CursorLocation \u30d7\u30ed\u30d1\u30c6\u30a3<\/strong>\u306b <strong>adUseClient<\/strong> \u3092\u8a2d\u5b9a\u3057\u305f\u5834\u5408\u306f\u3001\u3059\u3079\u3066\u306e\u30ab\u30fc\u30bd\u30eb\u30bf\u30a4\u30d7\u3067\u3001\u30ec\u30b3\u30fc\u30c9\u6570\u304c\u623b\u308a\u5024\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<div class=\"m30-l\">\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011\u3000<\/strong><em>object<\/em>.<strong>CursorLocation<\/strong> = \uff1c\u30ab\u30fc\u30bd\u30eb\u30ed\u30b1\u30fc\u30b7\u30e7\u30f3\uff1e<\/div>\n<p>\t\u203b\u3000<em>object<\/em>\u3000\u2026\u3000<strong>Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><br \/>\n\t<\/p>\n<table>\n<tr>\n<td align = \"center\" width=\"250\" bgcolor=\"#ffffccc\"><strong>\u30ab\u30fc\u30bd\u30eb\u30ed\u30b1\u30fc\u30b7\u30e7\u30f3<\/strong><\/td>\n<td align = \"center\" width=\"50\" bgcolor=\"#ffffccc\"><strong>\u5024<\/strong><\/td>\n<td align = \"center\" width=\"350\" bgcolor=\"#ffffccc\"><strong>\u5185\u5bb9<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"250\">adUseNone<\/td>\n<td width=\"50\" align = \"center\">1<\/td>\n<td width=\"350\">\u30ab\u30fc\u30bd\u30eb \u30b5\u30fc\u30d3\u30b9\u3092\u4f7f\u3044\u307e\u305b\u3093<\/td>\n<\/tr>\n<tr>\n<td width=\"250\">adUseServer<\/td>\n<td width=\"50\" align = \"center\">2<\/td>\n<td width=\"350\">\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u30ab\u30fc\u30bd\u30eb\uff08\u65e2\u5b9a\u5024\uff09<\/td>\n<\/tr>\n<tr>\n<td width=\"250\">adUseClient<\/td>\n<td width=\"50\" align = \"center\">3<\/td>\n<td width=\"350\">\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u30ab\u30fc\u30bd\u30eb<\/td>\n<\/tr>\n<\/table>\n<p>\n      <\/div>\n<\/p><\/div>\n<\/div>\n<br \/><br \/>\n<h2>RecordCount \u30d7\u30ed\u30d1\u30c6\u30a3 \u4f7f\u7528\u4f8b<\/h2>\n<div class=\"m30-l\">\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"RecordCount \u30d7\u30ed\u30d1\u30c6\u30a3\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_ADO_RecordCount()\r\n    \r\n    '\u53c2\u7167\u8a2d\u5b9a:Microsoft ActiveX Data Objects 6.1 Library\r\n    \r\n    Dim cn As ADODB.Connection\r\n    Dim rs As ADODB.Recordset\r\n    Dim constr As String\r\n    Dim DBFile As String\r\n    Dim strSQL As String\r\n    \r\n    DBFile = ActiveWorkbook.Path & \"\\mydb1.accdb\"\r\n    constr = \"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\" & DBFile\r\n    \r\n    Set cn = New ADODB.Connection\r\n    cn.ConnectionString = constr\r\n    cn.Open\r\n    \r\n    strSQL = \"Select * from \u793e\u54e1\u540d\u7c3f\"\r\n    \r\n    Set rs = New ADODB.Recordset\r\n    rs.CursorLocation = adUseClient\r\n    rs.CursorType = adOpenDynamic\r\n    \r\n    rs.Open strSQL, cn\r\n    Debug.Print rs.RecordCount\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:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/07\/adorecordcount_02.jpg?ssl=1\" rel=\"lightbox[6072]\"><img loading=\"lazy\" src=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/07\/adorecordcount_02.jpg?resize=580%2C357&#038;ssl=1\" alt=\"RecordCount \u30d7\u30ed\u30d1\u30c6\u30a3\uff08ADO\uff09\" width=\"580\" height=\"357\" class=\"alignnone size-large wp-image-6083\" srcset=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/07\/adorecordcount_02.jpg?resize=580%2C357&amp;ssl=1 580w, https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/07\/adorecordcount_02.jpg?resize=400%2C246&amp;ssl=1 400w, https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/07\/adorecordcount_02.jpg?resize=768%2C473&amp;ssl=1 768w, https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/07\/adorecordcount_02.jpg?w=841&amp;ssl=1 841w\" sizes=\"(max-width: 580px) 100vw, 580px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<\/div>\n<br \/><br \/>\n","protected":false},"excerpt":{"rendered":"<p>RecordCount \u30d7\u30ed\u30d1\u30c6\u30a3 Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30ec\u30b3\u30fc\u30c9\u6570 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":6083,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":""},"categories":[948],"tags":[973,953,950,721,968,970,952,951,814,955,949,835],"jetpack_featured_media_url":"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/07\/adorecordcount_02.jpg?fit=841%2C518&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4Ye9i-1zW","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/6072"}],"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=6072"}],"version-history":[{"count":12,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/6072\/revisions"}],"predecessor-version":[{"id":6221,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/6072\/revisions\/6221"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/6083"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=6072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=6072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=6072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}