{"id":6870,"date":"2019-06-16T06:21:06","date_gmt":"2019-06-15T21:21:06","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=6870"},"modified":"2023-05-28T08:47:00","modified_gmt":"2023-05-27T23:47:00","slug":"%e3%80%90c%e3%80%91%e3%83%87%e3%83%bc%e3%82%bf%e3%82%bb%e3%83%83%e3%83%88%e3%81%ae%e5%9f%ba%e6%9c%ac","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=6870","title":{"rendered":"\u3010C#\u3011\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8(DataSet)\u306e\u57fa\u672c"},"content":{"rendered":"<p>DataSet\u306f\u57fa\u672c\u7684\u306b\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u64cd\u4f5c\u306e\u969b\u306b\u4f7f\u7528\u3059\u308b<\/strong><\/span>C#\u306e\u30af\u30e9\u30b9\u306b\u306a\u308a\u307e\u3059\u3002DataSet\u306e\u4e2d\u306b\u8907\u6570\u306eDataTable\u3092\u683c\u7d0d\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u5229\u7528\u3059\u308b\u969b\u306f\u3001DB\u975e\u63a5\u7d9a\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>DataSet<\/h2>\n<p><span style=\"color: #ff0000;\"><strong>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u8907\u6570\u306e\u7d50\u679c\u30c6\u30fc\u30d6\u30eb<\/strong><\/span>\u3092\u6271\u3044\u307e\u3059\u3002DataSet\u306e\u4e2d\u306b\u306f\u3001<span style=\"color: #ff0000;\"><strong>DataTable<\/strong><\/span>\u3092\u683c\u7d0d\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h3>DataTable\u306e\u53d6\u5f97\u65b9\u6cd5<\/h3>\n<pre class=\"lang:default decode:true \">##\u756a\u53f7\u3092\u6307\u5b9a\u3059\u308b\u65b9\u6cd5\r\nDataSet\u30aa\u30d6\u30b8\u30a7\u30af\u30c8.Tables[\u756a\u53f7]\r\n\r\n##\u30c6\u30fc\u30d6\u30eb\u540d\u3092\u6307\u5b9a\u3059\u308b\u65b9\u6cd5\r\nDataSet\u30aa\u30d6\u30b8\u30a7\u30af\u30c8.Tables[\u30c6\u30fc\u30d6\u30eb\u540d]\r\n<\/pre>\n<h2>DataTable<\/h2>\n<p><span style=\"color: #ff0000;\"><strong>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u5358\u6570\u306e\u7d50\u679c\u30c6\u30fc\u30d6\u30eb<\/strong><\/span>\u3092\u6271\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30ec\u30b3\u30fc\u30c9\u306e\u96c6\u5408<\/h3>\n<p>DataTable\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u306e\u30ec\u30b3\u30fc\u30c9\u306e\u96c6\u5408\u306f\u3001<span style=\"color: #ff0000;\"><strong>DataRowCollection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u306b\u306a\u308a\u307e\u3059\u3002DataRowCollection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306f\u3001\u5404\u30ec\u30b3\u30fc\u30c9\u3092\u8868\u3059<span style=\"color: #ff0000;\"><strong>DataRow\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4>DataRowCollection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u53d6\u5f97\u65b9\u6cd5<\/h4>\n<pre class=\"lang:default decode:true\">DataTable\u30aa\u30d6\u30b8\u30a7\u30af\u30c8.Rows<\/pre>\n<h4>DataRowCollection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304b\u3089\u3001DataRow\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u53d6\u5f97\u6cd5<\/h4>\n<p>\uff12\u3064\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><strong>1.<span style=\"color: #ff0000;\">foreach\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/span>\u306b\u3066\u9806\u306b\u53c2\u7167\u3059\u308b\u65b9\u6cd5<\/strong><\/p>\n<pre class=\"lang:default decode:true\">foreach (DataRow\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 in DataRowCollection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8)\r\n{\r\n    DataRow\u30aa\u30d6\u30b8\u30a7\u30af\u30c8.ItemArray\uff08DataRow\u306e\u5404\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u5024\u3092object\u914d\u5217\u3067\u8fd4\u3059\u3002\uff09\r\n}<\/pre>\n<p><strong>2.\u884c\u756a\u53f7\u3092\u6307\u5b9a\u3057\u3066\u53d6\u5f97\u3059\u308b\u65b9\u6cd5<\/strong><\/p>\n<pre class=\"lang:default decode:true \">##DataRow\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u53d6\u5f97\r\nDataTable\u30aa\u30d6\u30b8\u30a7\u30af\u30c8.Rows[\u884c\u756a\u53f7]\r\n\r\n##DataRow\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304b\u3089\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u53d6\u5f97\r\nDataRow\u30aa\u30d6\u30b8\u30a7\u30af\u30c8.[\u5217\u756a\u53f7]\r\nor\r\nDataRow\u30aa\u30d6\u30b8\u30a7\u30af\u30c8.[\u30d5\u30a3\u30fc\u30eb\u30c9\u540d]\r\n\r\n<\/pre>\n<h2>OleDbDataAdapter<\/h2>\n<p>DataSet\u3084DataTable\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3059\u308b\u969b\u306b\u5fc5\u8981\u3068\u306a\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3059\u3002<\/p>\n<h3>\u547c\u3073\u51fa\u3057\u306e\u4f8b\u6587<\/h3>\n<pre class=\"lang:default decode:true\">new System.Data.OleDb.OleDbDataAdapter(SQL\u6587, OleDbConnection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8);<\/pre>\n<h3>\u30c7\u30fc\u30bf\u306e\u683c\u7d0d\uff08Fill\u30e1\u30bd\u30c3\u30c9\uff09<\/h3>\n<p>Fill\u30e1\u30bd\u30c3\u30c9\u306b\u3066\u3001DataSet\u3084DataTable\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002<\/p>\n<h4>\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u683c\u7d0d\u3059\u308b\u4f8b<\/h4>\n<pre class=\"lang:default decode:true\">OleDbDataAdapter\u30aa\u30d6\u30b8\u30a7\u30af\u30c8.Fill(\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8,\u30c6\u30fc\u30d6\u30eb\u540d)<\/pre>\n<h4>\u30c7\u30fc\u30bf\u30c6\u30fc\u30d6\u30eb\u306b\u683c\u7d0d\u3059\u308b\u4f8b<\/h4>\n<pre class=\"lang:default decode:true  \">OleDbDataAdapter\u30aa\u30d6\u30b8\u30a7\u30af\u30c8.Fill(\u30c7\u30fc\u30bf\u30c6\u30fc\u30d6\u30eb)<\/pre>\n","protected":false},"excerpt":{"rendered":"DataSet\u306f\u57fa\u672c\u7684\u306b\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u64cd\u4f5c\u306e\u969b\u306b\u4f7f\u7528\u3059\u308bC#\u306e\u30af\u30e9\u30b9\u306b\u306a\u308a\u307e\u3059\u3002DataSet\u306e\u4e2d\u306b\u8907\u6570\u306eDataTable\u3092\u683c\u7d0d\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u5229\u7528\u3059\u308b\u969b\u306f\u3001DB\u975e\u63a5\u7d9a\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u306a\u308a\u307e\u3059\u3002 Dat [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[158],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/6870"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6870"}],"version-history":[{"count":17,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/6870\/revisions"}],"predecessor-version":[{"id":20794,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/6870\/revisions\/20794"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6870"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}