{"id":110,"date":"2018-12-07T23:23:03","date_gmt":"2018-12-07T14:23:03","guid":{"rendered":"https:\/\/r-side.net\/?p=110"},"modified":"2020-05-09T15:56:15","modified_gmt":"2020-05-09T06:56:15","slug":"post-110","status":"publish","type":"post","link":"https:\/\/r-side.net\/?p=110","title":{"rendered":"VB.NET2015\u304b\u3089SQL Server\u306e\u30c7\u30fc\u30bf\u3092\u66f4\u65b0\u3059\u308b(ADO.NET)"},"content":{"rendered":"<p>SQL\u3067\u30c7\u30fc\u30bf\u3092\u66f4\u65b0\u3059\u308b\u5834\u5408\u306f\u3001INSERT\u6587\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<br \/>\nSqlCommand\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u3001CommandText\u306bSQL\u6587\u3092\u6307\u5b9a\u3057\u3066\u3001ExecuteNonQuery()\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vbnet decode:true\" title=\"UPDATE\u306b\u3088\u308b\u30c7\u30fc\u30bf\u306e\u66f4\u65b0\">    '\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u66f4\u65b0\r\n    Private Sub SqlUpdate()\r\n        Dim command As System.Data.SqlClient.SqlCommand = Con.CreateCommand()\r\n        '\u5b9f\u884c\u3059\u308bSQL\u30af\u30a8\u30ea\u30fc\u3092\u6307\u5b9a\r\n        command.CommandText = \"UPDATE FileList SET Name = @Name,Date = @Date,Size = @Size\"\r\n        '\u7d50\u679c\u304c\u8fd4\u3063\u3066\u304f\u308b\u307e\u3067\u5f85\u6a5f\u3059\u308b\u79d2\u6570\r\n        command.CommandTimeout = 30\r\n        '\u5909\u63db\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306e\u8a2d\u5b9a\r\n        command.Parameters.Add(\"@Name\", SqlDbType.NVarChar).Value = \"\u540d\u79f0\"\r\n        command.Parameters.Add(\"@Date\", SqlDbType.DateTime).Value = DateTime.Parse(\"2018\/12\/07 12:34:56\")\r\n        command.Parameters.Add(\"@Size\", SqlDbType.BigInt).Value = 1000\r\n        ' \u6307\u5b9a\u3057\u305f SQL \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\r\n        command.ExecuteNonQuery()\r\n        command.Dispose()\r\n    End Sub<\/pre>\n<pre class=\"lang:c# decode:true \" title=\"UPDATE\u306b\u3088\u308b\u30c7\u30fc\u30bf\u306e\u66f4\u65b0(C#)\">\/\/\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u66f4\u65b0\r\nprivate void SqlUpdate() {\r\n    System.Data.SqlClient.SqlCommand command = Con.CreateCommand();\r\n    \/\/\u5b9f\u884c\u3059\u308bSQL\u30af\u30a8\u30ea\u30fc\u3092\u6307\u5b9a\r\n    command.CommandText = \"UPDATE FileList SET Name = @Name,Date = @Date,Size = @Size\";\r\n    \/\/\u7d50\u679c\u304c\u8fd4\u3063\u3066\u304f\u308b\u307e\u3067\u5f85\u6a5f\u3059\u308b\u79d2\u6570\r\n    command.CommandTimeout = 30;\r\n    \/\/\u5909\u63db\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306e\u8a2d\u5b9a\r\n    command.Parameters.Add(\"@Name\", SqlDbType.NVarChar).Value = \"\u540d\u79f0\";\r\n    command.Parameters.Add(\"@Date\", SqlDbType.DateTime).Value = DateTime.Parse(\"2018\/12\/07 12:34:56\");\r\n    command.Parameters.Add(\"@Size\", SqlDbType.BigInt).Value = 1000;\r\n    \/\/\u6307\u5b9a\u3057\u305f SQL \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\r\n    command.ExecuteNonQuery();\r\n    command.Dispose();\r\n}<\/pre>\n<p>\u4f7f\u3044\u65b9\u306f\u3001<br \/>\n\u30fbDim command As System.Data.SqlClient.SqlCommand = Con.CreateCommand()<br \/>\n\u3000\u306b\u3066\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306econ\u304b\u3089SqlCommand\u30af\u30e9\u30b9\u3092\u4f5c\u308a\u307e\u3059\u3002<br \/>\n\u30fbcommand.CommandText =<br \/>\n\u3000\u201dUPDATE FileList SET Name = @Name,Date = @Date,Size = @Size&#8221;<br \/>\n\u3000\u306b\u3066\u3001\u5909\u66f4\u3059\u308b\u9805\u76ee\u3068\u5909\u66f4\u5024\u3092\u5165\u529b\u3057\u307e\u3059\u3002<br \/>\n\u3000@\u540d\u79f0\u3068\u3059\u308b\u3053\u3068\u3067\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u5909\u6570\u3068\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u30fbcommand.Parameters.Add(\u201c@Name\u201d, SqlDbType.NVarChar).Value = \u201c\u540d\u79f0\u201d<br \/>\n\u3000\u30d1\u30e9\u30e1\u30fc\u30bf\u5909\u6570\u306b\u5024\u3092\u30bb\u30c3\u30c8\u3059\u308b\u305f\u3081\u306b\u3001Parameters.Add\u3092\u884c\u3044\u307e\u3059\u3002<br \/>\n\u3000Add\u306e\u5f15\u6570\u306f\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u540d\u3001\u30c7\u30fc\u30bf\u578b(SqlDbType)\u3092\u6307\u5b9a\u3057\u3001<br \/>\n\u3000.Value\u306b\u5024\u3092\u4ee3\u5165\u3059\u308b\u3060\u3051\u3067\u3059\u3002<br \/>\n\u30fbcommand.ExecuteNonQuery()\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u6ce8\u610f\u70b9\u306f\u3001\u4e0a\u8a18\u30bd\u30fc\u30b9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u4e0a\u306e\u3059\u3079\u3066\u306e\u5185\u5bb9\u304c\u6307\u5b9a\u3057\u305f\u5024\u306b\u66f8\u304d\u63db\u3048\u3089\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<br \/>\nUPDATE &lt;\u30c6\u30fc\u30d6\u30eb\u540d&gt; SET &lt;\u5217\u540d&gt;= &lt;\u5f0f&gt; WHERE &lt;\u6761\u4ef6&gt;<br \/>\n\u306e\u69d8\u306b\u3001WHERE\u306b\u6761\u4ef6\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u7279\u5b9a\u306e\u9805\u76ee\u3060\u3051\u66f8\u304d\u63db\u3048\u308b\u4e8b\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3044\u307e\u307e\u3067\u4f7f\u3063\u3066\u304d\u305f\u30c6\u30fc\u30d6\u30eb\u306b\u306f\u3001\u884c\u3092\u7279\u5b9a\u3059\u308b\u5024\u304c\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u306e\u3067\u3001\u30ad\u30fc\u3068\u306a\u308bId\u306e\u9805\u76ee\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002SQL Server\u3067\u306fIDENTITY\u306e\u6307\u5b9a\u3092\u884c\u3046\u3053\u3068\u3067\u3001\u81ea\u52d5\u63a1\u756a\u3068\u3057\u3066\u8ffd\u52a0\u6bce\u306b\u81ea\u52d5\u3067\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3055\u308c\u308b\u9805\u76ee\u3092\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u5f8c\u306fWHERE Id=1\u3068\u3044\u3063\u305f\u6307\u5b9a\u3092\u3059\u308b\u3053\u3068\u3067\u3001\u7279\u5b9a\u306e\u884c\u306e\u307f\u66f8\u304d\u63db\u3048\u308b\u4e8b\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0a\u304c\u3001\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3068\u306a\u308a\u307e\u3059\u306e\u3067\u3001SQL\u6587\u3092\u4f7f\u3044ExecuteReader()\u304bExecuteNonQuery()\u3092\u4f7f\u3046\u3053\u3068\u3067\u5927\u62b5\u306e\u4e8b\u306f\u51fa\u6765\u308b\u306e\u3067\u306f\u7121\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL\u3067\u30c7\u30fc\u30bf\u3092\u66f4\u65b0\u3059\u308b\u5834\u5408\u306f\u3001INSERT\u6587\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 SqlCommand\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u3001CommandText\u306bSQL\u6587\u3092\u6307\u5b9a\u3057\u3066\u3001ExecuteNonQuery()\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002 &#8216;\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u66f4\u65b0 Pri [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[27,19,18],"class_list":["post-110","post","type-post","status-publish","format-standard","hentry","category-vbsql","tag-c","tag-sql","tag-vb-net"],"_links":{"self":[{"href":"https:\/\/r-side.net\/index.php?rest_route=\/wp\/v2\/posts\/110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/r-side.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/r-side.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/r-side.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/r-side.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=110"}],"version-history":[{"count":3,"href":"https:\/\/r-side.net\/index.php?rest_route=\/wp\/v2\/posts\/110\/revisions"}],"predecessor-version":[{"id":146,"href":"https:\/\/r-side.net\/index.php?rest_route=\/wp\/v2\/posts\/110\/revisions\/146"}],"wp:attachment":[{"href":"https:\/\/r-side.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/r-side.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/r-side.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}