{"id":2293,"date":"2011-08-04T11:39:18","date_gmt":"2011-08-04T02:39:18","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/?p=2293"},"modified":"2011-08-05T00:46:10","modified_gmt":"2011-08-04T15:46:10","slug":"visual-basic-%e3%81%ae%e3%83%aa%e3%83%95%e3%82%a1%e3%82%af%e3%82%bf%e3%83%aa%e3%83%b3%e3%82%b0%e3%83%9d%e3%82%a4%e3%83%b3%e3%83%88%ef%bc%88%e4%b8%8a%e6%b5%b7%e7%b7%a8%ef%bc%89","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/2293","title":{"rendered":"Visual Basic \u306e\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u30dd\u30a4\u30f3\u30c8\uff08\u4e0a\u6d77\u7de8\uff09"},"content":{"rendered":"<p>\u540d\u8457\u300c\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u300d\u306b\u6cbf\u3063\u3066\u3001\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u305b\u3088\u30c3!!! \u3068\u3044\u3046\u306e\u306f\u96e3\u3057\u3044\u306e\u3067\u3001\u5177\u4f53\u7684\u306a\u30dd\u30a4\u30f3\u30c8\u3092\u51fa\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u524d\u306b\u524d\u63d0\u6761\u4ef6\u304c\u3042\u3063\u3066\u3001<\/p>\n<p>1.NUnit \u3067\u7a0b\u3088\u304f\u3001\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u304c\u66f8\u304b\u308c\u3066\u3044\u308b\u3053\u3068\u3002<br \/>\n2.\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u30c4\u30fc\u30eb(VSS\u3084SVN\u306a\u3069)\u304c\u5c0e\u5165\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3002<\/p>\n<p>\u304c\u6761\u4ef6\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u300c\u7a0b\u3088\u304f\u300dNunit \u304c\u4f7f\u308f\u308c\u3066\u3044\u308b\u3068\u3044\u3046\u306e\u306f\u3001\u95a2\u6570\u306e\u4e2d\u8eab\u3092\u5f04\u308b\u306e\u3067 NUnit \u306e\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u901a\u3057\u306a\u304c\u3089\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u3057\u305f\u3044\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002\u6ce8\u610f\u6df1\u304f\u3084\u308c\u3070\u7279\u306b\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u306f\u3044\u3089\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u624b\u9806\u3092\u9593\u9055\u3048\u305f\u3068\u304d\uff08\u4eba\u70ba\u7684\u306a\u30df\u30b9\u3067\u3059\u306d\uff09\u306e\u767a\u898b\u304c\u65e9\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u540c\u6642\u306b\u3001\u9593\u9055\u3048\u305f\u30bd\u30fc\u30b9\u3092\u5143\u306b\u623b\u3059\u306e\u306b\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u30c4\u30fc\u30eb\u304c\u5fc5\u8981\u3067\u3059\u3002\u5b9f\u306f\u3053\u308c\u3082\u5fc5\u9808\u3068\u3044\u3046\u308f\u3051\u3067\u306f\u306a\u304f\u3001\u81ea\u524d\u3067\u30d0\u30c3\u30b0\u30a2\u30c3\u30d7\u3092\u53d6\u308a\u306a\u304c\u3089\u3067\u3082\u3088\u3044\u306e\u3067\u3059\u304c\u3001\u4fee\u6b63\u524d\u306e\u5dee\u5206\u3084\u3001\u4e00\u6c17\u306b\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u623b\u3057\u3066\u3057\u307e\u3046\u3053\u3068\u3082\u53ef\u80fd\u306a\u306e\u3067\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u30c4\u30fc\u30eb\u304c\u3042\u308b\u3068\u5b89\u5168\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3069\u3061\u3089\u3082\u3001\u3010\u30bb\u30fc\u30d5\u30c6\u30a3\u30cd\u30c3\u30c8\u3011\u306e\u5f79\u5272\u304c\u5f37\u3044\u3067\u3059\u3002<\/p>\n<p>\u3055\u3066\u3001\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u3068\u8a00\u3048\u3070\u3001\u666e\u901a\u306f\u95a2\u6570\u306e\u5171\u901a\u5316\u304c\u4e3b\u306a\u4f5c\u696d\u306b\u306a\u308b\u306e\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u3010\u30b3\u30fc\u30c9\u81ea\u4f53\u306e\u8cea\u3011\u3092\u4e0a\u3052\u308b\u3053\u3068\u306b\u6ce8\u529b\u3057\u307e\u3059\u3002\u3068\u8a00\u3046\u306e\u3082\u3001\u307d\u308d\u307d\u308d\u3068\u5999\u306a\u66f8\u304d\u65b9\u3092\u3055\u308c\u3066\u3044\u308b\u3068\u3053\u308d\u304c\u591a\u304f\u3001\u30b3\u30fc\u30c9\u304c\u7d71\u4e00\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u5f8c\u304b\u3089\u306e\u4fdd\u5b88\u304c\u5927\u5909\u304b\u3064\u30b7\u30b9\u30c6\u30e0\u8a66\u9a13\u6642\u306b\u9867\u5ba2\u8981\u671b\u3092\u53d6\u308a\u5165\u308c\u306b\u304f\u3044\uff08\u30b3\u30fc\u30c9\u3092\u65e9\u6025\u306b\u6539\u4fee\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u5834\u5408\u306b\u3001\u6642\u9593\u304c\u639b\u304b\u3063\u3066\u3057\u307e\u3046\uff09\u3068\u3044\u3046\u6b20\u70b9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30fb\u30c7\u30d0\u30c3\u30b0\u3057\u3084\u3059\u3044\u30b3\u30fc\u30c9\u306b\u76f4\u3057\u3001\u30c7\u30d0\u30c3\u30b0\u6642\u9593\u3092\u6e1b\u3089\u3059\u3002<br \/>\n\u30fb\u4fdd\u5b88\u3057\u6613\u3044\u30b3\u30fc\u30c9\u306b\u66f8\u304d\u76f4\u3057\u3001\u4fdd\u5b88\u53ef\u80fd\u306a\u30b3\u30fc\u30c9\u306b\u3059\u308b\u3002<\/p>\n<p>\u306e\u304c\u4e3b\u76ee\u7684\u3067\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u8a33\u3067\u3001\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u5bfe\u8c61\u306e\u4e2d\u3067\u3001\u516c\u958b\u3057\u3066\u3082\u5dee\u3057\u652f\u3048\u306a\u3044\u3068\u3053\u308d\u3092\u3044\u304f\u3064\u304b\u6652\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002\u30b3\u30fc\u30c9\u306f Visual Basic \u306a\u306e\u3067\u3059\u304c\u3001C# \u306b\u3082\u3042\u3066\u306f\u307e\u308a\u307e\u3059\u3002<\/p>\n<p>\u25a0if \u6587\u306b not \u3092\u4f7f\u308f\u306a\u3044<\/p>\n<p>\u95a2\u6570\u304c Function Method() As Boolean \u3067\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u3068\u304d\u306b\u3001True\/False \u3067\u8fd4\u3059\u3082\u306e\u3060\u304b\u3089\u3001<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nif obj.Method() Then\r\n  ...\r\nend if\r\n<\/pre>\n<p>\u3068\u3084\u308a\u305f\u304f\u306a\u308b\u306e\u3067\u3059\u304c\u3001<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nif not obj.Method() Then\r\n  ...\r\nend if\r\n<\/pre>\n<p>\u306e\u30b3\u30fc\u30c9\u304c\u6563\u898b\u3055\u308c\u305f\u306e\u3067\u3001True\/False \u4ed8\u304d\u306b\u5909\u3048\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nif obj.Method() = True Then\r\n  ...\r\nend if\r\n\r\n\u3042\u308b\u3044\u306f\r\n\r\nif obj.Method() = False Then\r\n  ...\r\nend if\r\n<\/pre>\n<p>\u306b\u3057\u3066\u3001\u660e\u793a\u7684\u306b boolean \u3068\u6bd4\u8f03\u3057\u307e\u3059\u3002\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30d0\u30c3\u30b0\u6642\u306b\u3069\u3061\u3089\u3067\u6bd4\u8f03\u3057\u3066\u3044\u308b\u306e\u304b\u4e00\u77ac\u3067\u5206\u304b\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u3041\u3001\u4e3b\u539f\u56e0\u306f\u2193\u306a\u30b3\u30fc\u30c9\u304c\u3042\u3063\u3066\u3001\u4f55\u3092\u3084\u3063\u3066\u3044\u308b\u3084\u3089&#8230;\u3063\u3066\u611f\u3058\u3060\u3063\u305f\u306e\u304c\u672c\u97f3\u3067\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nif not obj.Method() &lt;&gt; 1 Then\r\n  ...\r\nend if\r\n<\/pre>\n<p>\u25a0if \u6587\u5185\u3067 end sub\/function \u3057\u305f\u6642\u306f else \u3092\u66f8\u304b\u306a\u3044<\/p>\n<p>\u5177\u4f53\u7684\u306b\u306f\u3001<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nif param &lt; 0 Then\r\n  &#039; \u7570\u5e38\u7cfb\r\n  ...\r\n  end sub\r\nelse\r\n  &#039; \u6b63\u5e38\u7cfb\r\n  ...\r\nend if\r\n<\/pre>\n<p>\u3088\u304f\u3042\u308b\u3001if \u6587\u3067\u30d1\u30e9\u30e1\u30fc\u30bf\u306a\u3069\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u30a8\u30e9\u30fc\u3092\u306f\u3058\u304f\u3068\u3044\u3046\u51e6\u7406\u306a\u306e\u3067\u3059\u304c\u3001else \u306e\u524d\u3067 exit sub(return \u306a\u3069\u3082) \u3092\u3057\u3066\u95a2\u6570\u3092\u629c\u3051\u3066\u3044\u307e\u3059\u3002\u306a\u306e\u3067\u3001else \u306e\u3068\u3053\u308d\u3063\u3066\u610f\u5473\u304c\u306a\u3044\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u666e\u901a\u306b\u2193\u306a\u98a8\u306b\u66f8\u304d\u307e\u3057\u3087\u3046\u3088\u3001\u3068\u3044\u3046\u8a71\u3067\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nif param &lt; 0 Then\r\n  &#039; \u7570\u5e38\u7cfb\r\n  ...\r\n  end sub\r\nend if\r\n&#039; \u6b63\u5e38\u7cfb\r\n...\r\n<\/pre>\n<p>\u5b9f\u306f\u3001\u3053\u308c\u3001\u3048\u3089\u3044\u30b3\u30fc\u30c9\u304c\u3042\u3063\u3066\u3001\u2193\u306a\u30b3\u30fc\u30c9\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nif param1 &lt; 0 then\r\n  &#039; \u7570\u5e38\u51e6\u7406\r\n  end sub\r\nelse\r\n  if param2 &lt; 0 then\r\n    &#039; \u7570\u5e38\u51e6\u7406\r\n    end sub\r\n  else\r\n    if param3 &lt; 0 then\r\n      &#039; \u7570\u5e38\u51e6\u7406\r\n    else\r\n      &#039; \u6b63\u5e38\u51e6\u7406\r\n      ...\r\n    end if\r\n  end if\r\nend if\r\n<\/pre>\n<p>\u6b63\u5e38\u7cfb\u306e\u51e6\u7406\u3092\u3084\u308a\u305f\u3044\u306e\u3084\u3089\u3001\u7570\u5e38\u51e6\u7406\u304c\u3084\u308a\u305f\u3044\u306e\u3084\u3089\u5206\u304b\u308a\u307e\u305b\u3093&#8230;\u3063\u3066\u306a\u5177\u5408\u3002<\/p>\n<p>\u25a0\u95a2\u6570\u306e\u623b\u308a\u5024\u306f\u610f\u5473\u306e\u3042\u308b\u5834\u5408\u3060\u3051\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/p>\n<p>\u3061\u3087\u3063\u3068\u30ed\u30fc\u30ab\u30eb\u30eb\u30fc\u30eb\u81ed\u3044\u306e\u3067\u3059\u304c\u3001\u3053\u3093\u306a\u30b3\u30fc\u30c9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nfunction Method() as Boolean\r\n  ...\r\n  if ... then\r\n    ' \u30a8\u30e9\u30fc\u306e\u5834\u5408\u3001\u4f8b\u5916\u3092\u767a\u751f\u3055\u305b\u308b\r\n    throw new Exception(...)\r\n  end if\r\n  return true\r\nend function\r\n<\/pre>\n<p>\u3068\u3044\u3046\u95a2\u6570\u304c\u3042\u308a\u307e\u3059\u3002\u623b\u308a\u5024\u304c True \u3057\u304b\u306a\u3044\u306e\u306b\u3001Function \u306b\u3057\u3066\u3044\u308b\u306e\u304c\u304a\u304b\u3057\u3044\u3001\u306e\u306f\u78ba\u304b\u306b\u8a00\u3048\u3066\u3001\u672c\u6765\u306f sub \u306b\u3057\u307e\u3059\u306d(C# \u306a\u3089\u3070 void\u578b)\u3002<\/p>\n<p>\u3053\u308c\u3092\u5229\u7528\u3059\u308b\u3068\u304d\u306b\u3001\u5f8b\u5100\u306b\u3001<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nif obj.Method() = false then\r\n  ' \u7570\u5e38\u7cfb\r\n  ...\r\n  end sub\r\nend if\r\n<\/pre>\n<p>\u3057\u3066\u3044\u308b\u30b3\u30fc\u30c9\u304c\u7d50\u69cb\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u307e\u3041\u3001Function \u3060\u3057\u623b\u308a\u5024\u3092\u78ba\u8a8d\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u306f\u7b4b\u306a\u3093\u3067\u3059\u304c&#8230;\u3002\u3053\u308c\u3092\u3044\u3056\u3001\u4fdd\u5b88\u3057\u3088\u3046\u3068\u3057\u305f\u3068\u304d\u306b Method \u304c True\/False \u3092\u8fd4\u3059\u306e\u304b? \u3063\u3066\u8abf\u3079\u306a\u3044\u3068\u99c4\u76ee\u306a\u3093\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001\u5185\u90e8\u3067\u4f8b\u5916\u3057\u304b\u767a\u751f\u3055\u305b\u3066\u3044\u306a\u3044\u3057\u3001\u305d\u306e\u4f8b\u5916\u306f catch \u3057\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u5358\u7d14\u306a\u51e6\u7406\u306e\u8a18\u8ff0\u3068\u3057\u3066\u66f8\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nobj.Method()\r\n<\/pre>\n<p>\u5b9f\u306f\u3001\u4eca\u56de\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e\u30ed\u30fc\u30ab\u30eb\u30eb\u30fc\u30eb\u3067\u300c\u57fa\u672c\u7684\u306b\u4f8b\u5916\u3092\u767a\u751f\u3055\u305b\u306a\u3044\u300d\u3068\u3044\u3046\u3082\u306e\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002DB \u3092\u6271\u3046\u306e\u3067\u3001SqlCommand \u95a2\u4fc2\u306e\u30a8\u30e9\u30fc\uff08\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u7b49\uff09\u3057\u304b\u767a\u751f\u3057\u306a\u3044\u306e\u3067\u3001\u3053\u306e\u624b\u306e\u4f8b\u5916\u306f\u3082\u3063\u3068\u5916\u90e8\u306e\u307b\u3046\u3067\u53d6\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3068\u3044\u3046\u7406\u7531\u304c\u3042\u3063\u3066\u3001\u4f8b\u5916\u51e6\u7406\u3092\u3054\u3061\u3083\u3054\u3061\u3083\u3084\u308a\u305f\u304f\u306a\u304b\u3063\u305f\u3001\u3068\u3044\u3046\u306e\u304c\u3042\u3063\u3066\u306e\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u5bfe\u8c61\u3067\u3059\u3002<\/p>\n<p>\u307e\u3041\u3001\u672c\u6765\u306f Fuction \u3058\u3083\u306a\u304f\u3066\u3001Sub \u306b\u3059\u308b\u306e\u304c\u6b63\u5f0f\u3067\u3059\u304b\u306d\u3002<\/p>\n<p>\u25a0DataTable.Rows(0) \u3092\u76f4\u63a5\u53c2\u7167\u3057\u306a\u3044<\/p>\n<p>\u4eca\u56de\u306f\u3001DAO \u3068\u3044\u3046\u5f62\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30a2\u30af\u30bb\u30b9\u3092\u3059\u308b\u30af\u30e9\u30b9\u3092\u5fc5\u305a\u4f5c\u308a\u307e\u3057\u305f\u3002<br \/>\nO\/R \u30de\u30c3\u30d4\u30f3\u30b0\u7684\u306b\u8a00\u3048\u3070\u3001DAO \u81ea\u4f53\u306b\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u8a2d\u8a08\u6642\u9593\u7684\u306b\u4f59\u88d5\u304c\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u305d\u306e\u3042\u305f\u308a\u306f\u98db\u3070\u3057\u3066\u3001DataTable \u3092\u76f4\u63a5\u6271\u3046\u3068\u3053\u308d\u304c\u591a\u3005\u3042\u308a\u307e\u3059\uff08\u5b9f\u969b\u306b\u306f\u3001\u81ea\u4f5c\u306e\u578b\u4ed8DataTable\u306b\u81ea\u52d5\u30de\u30c3\u30d4\u30f3\u30b0\u3055\u305b\u3066\u3044\u307e\u3059\u304c\uff09\u3002<\/p>\n<p>\u3053\u306e\u4e2d\u3067\u3001\u4e3b\u30ad\u30fc\u306a\u3069\u3067\u691c\u7d22\u3057\u305f\u5834\u5408\u3001\u5fc5\u305a1\u4ef6\u3042\u308b\u3068\u3046\u60f3\u5b9a\u3067\u66f8\u304b\u308c\u3066\u3044\u308b\u30b3\u30fc\u30c9\u304c\u7d50\u69cb\u3042\u3063\u305f\u306e\u3067\u3001\u3053\u308c\u3092\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u5bfe\u8c61\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\ndim dt as new datatable\r\nda.fill( dt )\r\n\r\ndim id as integer = dt.rows(0)(&quot;ID&quot;)\r\ndim name as string = dt.rows(0)(&quot;NAME&quot;)\r\n...\r\n<\/pre>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7684\u306b\u6574\u5408\u6027\u304c\u3042\u3063\u3066\u3044\u308c\u3070\u30011\u4ef6\u306f\u53d6\u5f97\u3067\u304d\u308b\u305f\u3081\u3053\u3053\u3067\u843d\u3061\u308b\u3053\u3068\u306f\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u521d\u671f\u30c7\u30fc\u30bf\u306e\u7d61\u307f\u3082\u3042\u3063\u3066\uff08\u73fe\u72b6\u306e\u30b3\u30fc\u30c9\u306e\u54c1\u8cea\u3082\u52a0\u5473\u3057\u3066\uff09\u3001Rows.Count \u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\ndim dt as new datatable\r\nda.fill( dt )\r\nif dt.Rows.Count = 0 then \r\n  exit sub\r\nend if\r\n\r\ndim row as datarow = dt.rows(0)\r\ndim id as integer = row(&quot;ID&quot;)\r\ndim name as string = row(&quot;NAME&quot;)\r\n...\r\n<\/pre>\n<p>\u4e00\u6642\u5909\u6570\u306e row \u3092\u4f7f\u3046\u306e\u306f\u3001dt.Rows(0) \u304c\u3042\u3061\u3053\u3061\u306b\u51fa\u3066\u3053\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u3067\u3059\u3002<br \/>\n\u5143\u306e\u30b3\u30fc\u30c9\u306e\u307b\u3046\u304c\u3001dt.Rows(0) \u3092\u53c2\u7167\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u660e\u78ba\u306b\u306a\u308b\u306e\u306f\u78ba\u304b\u306a\u306e\u3067\u3059\u304c\u3001\u4fdd\u5b88\u3059\u308b\u3068\u304d\u306b\u300c\u305d\u308c\u306f\u3001Rows(1) \u3067\u306f\u306a\u3044\u306e\u304b\uff1f\u300d\u3068\u3044\u3046\u8ff7\u3044\u304c\u306a\u304f\u306a\u308a\u307e\u3059\u3002<br \/>\n\u306a\u306e\u3067\u3001VB \u306e\u5834\u5408\u306f With \u69cb\u6587\u3092\u4f7f\u3063\u3066\u3082 ok \u3067\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\ndim dt as new datatable\r\nda.fill( dt )\r\nif dt.Rows.Count = 0 then \r\n  exit sub\r\nend if\r\n\r\nWith dt.Rows(0)\r\n\tdim id as integer = .Item(&quot;ID&quot;)\r\n\tdim name as string = .Item(&quot;NAME&quot;)\r\nend with\r\n<\/pre>\n<p>\u25a0\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u306e\u7bc4\u56f2\u306f\u77ed\u304f\u3059\u308b<\/p>\n<p>\u3053\u308c\u306f\u30d0\u30b0\u542b\u307f\u306a\u306e\u3067\u3001\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u3068\u3044\u3046\u3088\u308a\u3082\u4fee\u6b63\u3067\u3059\u306d\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\ndim trans as new SqlTransaction\r\ntry\r\n\tdim cn as new SqlConnection(&quot;&quot;)\r\n\t...\r\n\ttrans.Connection = cn.BeginTransaction()\r\n\tif \u30d1\u30e9\u30e1\u30fc\u30bf\u30c1\u30a7\u30c3\u30af Then\r\n\t  ' \u7570\u5e38\u51e6\u7406\r\n\t  return False\r\n\tend if\r\n\t...\r\n\ttrans.Commit()\r\ncatch ex as SqlException\r\n    trans.RollBack\r\n    return False\r\nend try\r\nreturn true\r\n<\/pre>\n<p>\u3068\u3044\u3046\u30b3\u30fc\u30c9\u304c\u6563\u898b\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3059\u3002\u5b9f\u969b\u306b\u306f\u3001SqlTransaction, SqlConnection \u306f\u5225\u306e\u30af\u30e9\u30b9\u3067\u5b9f\u88c5\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u308c\u306e\u66f8\u304d\u65b9\u3067\u306f\u99c4\u76ee\u3067\u3059\u306d\u3002\u30d1\u30e9\u30e1\u30fc\u30bf\u30c1\u30a7\u30c3\u30af\u3067\u7570\u5e38\u51e6\u7406\u3092\u3057\u305f\u5f8c\u306b Rollback \u304c\u3067\u304d\u3066\u3044\u306a\u3044&#8230;\u3068\u3044\u3046\u304b\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u30c1\u30a7\u30c3\u30af\u306e\u524d\u3067\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3092\u958b\u59cb\u3057\u3066\u306f\u99c4\u76ee\u3067\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nif \u30d1\u30e9\u30e1\u30fc\u30bf\u30c1\u30a7\u30c3\u30af Then\r\n  ' \u7570\u5e38\u51e6\u7406\r\n  return False\r\nend if\r\n\r\ndim trans as new SqlTransaction\r\ntry\r\n\tdim cn as new SqlConnection(&quot;&quot;)\r\n\t...\r\n\ttrans.Connection = cn.BeginTransaction()\r\n\t...\r\n\ttrans.Commit()\r\ncatch ex as SqlException\r\n    trans.RollBack\r\n    return False\r\nend try\r\nreturn true\r\n<\/pre>\n<p>\u3053\u3093\u306a\u98a8\u306b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30a2\u30af\u30bb\u30b9\u3068\u306f\u95a2\u4fc2\u306a\u3044\u3082\u306e\u306f try \u306e\u524d\u306b\u66f8\u304b\u306a\u3044\u3068\u99c4\u76ee\u3067\u3059\u3002\u4f8b\u5916\u304c\u767a\u751f\u3055\u308c\u306a\u3044\u8a33\u3060\u3057\u3002<\/p>\n<p>\u3053\u308c\u306f\u30b3\u30fc\u30c9\u3092\u91cf\u7523\u3059\u308b\u3068\u304d\u306b\u8d77\u304d\u308b\u9593\u9055\u3044\u3067\u3001<\/p>\n<p>&#8211; \u307e\u305a\u306f\u3001\u95a2\u6570\u3092\u59cb\u3081\u305f\u3089 try &#8211; catch \u3067\u56f2\u3080<br \/>\n&#8211; \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u66f4\u65b0\u3059\u308b\u3068\u304d\u306f\u3001begintransaction \u3092\u66f8\u3044\u3066\u3057\u307e\u3046<\/p>\n<p>\u3068\u3044\u3046\u601d\u3044\u8fbc\u307f\u304c\u554f\u984c\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u672c\u6765\u306f\u3001<\/p>\n<p>&#8211; \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30a2\u30af\u30bb\u30b9\u6642\u306b\u306f\u4f8b\u5916\u304c\u767a\u751f\u3059\u308b\u306e\u3067\u3001try-catch \u3059\u308b\u3002<br \/>\n&#8211; \u30c7\u30fc\u30bf\u3092\u66f4\u65b0\u3059\u308b\u7bc4\u56f2\u3060\u3051\u3092\u3001\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3067\u56f2\u3080<\/p>\n<p>\u3068\u3044\u3046\u66f8\u304d\u65b9\u306b\u3057\u306a\u3044\u3068&#8230;\u3002<\/p>\n<p>\u305d\u3093\u306a\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u306e\u65e5\u3005\u3060\u3063\u305f\u308a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u540d\u8457\u300c\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u300d\u306b\u6cbf\u3063\u3066\u3001\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u305b\u3088\u30c3!!! \u3068\u3044\u3046\u306e\u306f\u96e3\u3057\u3044\u306e\u3067\u3001\u5177\u4f53\u7684\u306a\u30dd\u30a4\u30f3\u30c8\u3092\u51fa\u3057\u307e\u3059\u3002 \u3053\u306e\u524d\u306b\u524d\u63d0\u6761\u4ef6\u304c\u3042\u3063\u3066\u3001 1.NUnit \u3067\u7a0b\u3088\u304f\u3001\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u304c\u66f8\u304b\u308c\u3066\u3044\u308b\u3053\u3068\u3002 2.\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1 &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/2293\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-2293","post","type-post","status-publish","format-standard","hentry","category-dev"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=2293"}],"version-history":[{"count":3,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2293\/revisions"}],"predecessor-version":[{"id":2295,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2293\/revisions\/2295"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=2293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=2293"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=2293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}