{"id":528,"date":"2019-08-17T12:57:05","date_gmt":"2019-08-17T03:57:05","guid":{"rendered":"http:\/\/shinke1987.net\/?p=528"},"modified":"2019-10-17T18:59:49","modified_gmt":"2019-10-17T09:59:49","slug":"post-528","status":"publish","type":"post","link":"https:\/\/shinke1987.net\/?p=528","title":{"rendered":"C#\u304b\u3089ODBC\u7d4c\u7531\u3067PostgreSQL\u64cd\u4f5c\u3002"},"content":{"rendered":"\n<h2 id=\"toc0\" class=\"wp-block-heading\">\u74b0\u5883<\/h2>\n\n\n\n<p> VisualStudio2017Pro<br> .Net Framework 4.7.2<br> \u30b3\u30f3\u30bd\u30fc\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3<br> Windows10 Pro 64bit<br> ODBC\u30c9\u30e9\u30a4\u30d0\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u3002<\/p>\n\n\n\n<h2 id=\"toc1\" class=\"wp-block-heading\">\u5185\u5bb9<\/h2>\n\n\n\n<p>\u65e2\u306bPostgreSQL\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u3042\u308a\u3001<br>\u30c6\u30fc\u30d6\u30eb\u3084\u884c\u306e\u30c7\u30fc\u30bf\u304c\u5165\u3063\u3066\u3044\u308b\u72b6\u614b\u3002<br>\u305d\u3053\u304b\u3089\u3068\u308a\u3042\u3048\u305aSELECT\u6587\u3092\u5b9f\u884c\u3057\u305f\u30b5\u30f3\u30d7\u30eb\u3002<\/p>\n\n\n\n<h2 id=\"toc2\" class=\"wp-block-heading\">\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n\n\n\n<p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Data;\nusing System.Data.Odbc;\n\nnamespace DBTest\n{\n    class Program\n    {\n        static void Main(string&#x5B;] args)\n        {\n            String strConfig =\n                \/\/ \u30c9\u30e9\u30a4\u30d0\u540d\u306f\u300cODBC \u30c7\u30fc\u30bf \u30bd\u30fc\u30b9 \u30a2\u30c9\u30df\u30cb\u30b9\u30c8\u30ec\u30fc\u30bf\u30fc\u300d\u3067\u78ba\u8a8d\u3067\u304d\u308b\u3002\n                &quot;Driver={PostgreSQL Unicode(x64)};database=estimate;Server=192.168.1.9;Port=5432;Uid=UserName;Pwd=Password;CommandTimeOut=20;Timeout=5&quot;;\n\n            String strQuery =\n                &quot;SELECT detail1, writer FROM estimate &quot;\n                + &quot;WHERE writer='\u9069\u5f53\u306a\u6761\u4ef6';&quot;;\n\n            using (OdbcConnection connection = new OdbcConnection(strConfig))\n            {\n                OdbcCommand command = new OdbcCommand(strQuery, connection);\n\n                try\n                {\n                    connection.Open();\n                    \/\/ INSERT\u7b49\u306e\u884c\u3092\u8fd4\u3055\u306a\u3044SQL\u6587\u306e\u5834\u5408\u306f\u3001\u300cExecuteNonQuery\u300d\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3002\n                    OdbcDataReader reader = command.ExecuteReader();\n                    while (reader.Read())\n                    {\n                        Console.WriteLine(&quot;{0}\\t{1}&quot;, reader&#x5B;0], reader&#x5B;1]);\n                    }\n                    reader.Close();\n                }\n                catch (Exception e)\n                {\n                    Console.WriteLine(e.Message);\n                }\n                Console.ReadLine();\n            }\n        }\n    }\n}\n<\/pre>\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u74b0\u5883 VisualStudio2017Pro .Net Framework 4.7.2 \u30b3\u30f3\u30bd\u30fc\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 Windows10 Pro 64bit ODBC\u30c9\u30e9\u30a4\u30d0\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u3002 \u5185\u5bb9 \u65e2\u306bPostgreS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[36,57],"class_list":["post-528","post","type-post","status-publish","format-standard","hentry","category-c-sharp","tag-c-sharp","tag-postgresql"],"_links":{"self":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=528"}],"version-history":[{"count":6,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/528\/revisions"}],"predecessor-version":[{"id":582,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/528\/revisions\/582"}],"wp:attachment":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}