{"id":94,"date":"2018-12-05T22:51:22","date_gmt":"2018-12-05T13:51:22","guid":{"rendered":"https:\/\/r-side.net\/?p=94"},"modified":"2020-05-09T15:56:58","modified_gmt":"2020-05-09T06:56:58","slug":"post-94","status":"publish","type":"post","link":"https:\/\/r-side.net\/?p=94","title":{"rendered":"VB.NET2015(C#)\u304b\u3089SQL Server\u306b\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b(ADO.NET)"},"content":{"rendered":"<p>SQL\u3067\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\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=\"INSERT\u3068\u30d1\u30e9\u30e1\u30fc\u30bf\u6307\u5b9a\">   '\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u8ffd\u52a0\r\n    Private Sub SqlInsert()\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 = \"INSERT INTO FileList (Name,Date,Size) VALUES (@Name,@Date,@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\/06 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=\"INSERT\u3068\u30d1\u30e9\u30e1\u30fc\u30bf\u6307\u5b9a(C#)\">\/\/\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u8ffd\u52a0\r\nprivate void SqlInsert() {\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 = \"INSERT INTO FileList (Name,Date,Size) VALUES (@Name,@Date,@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\/06 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&#8221;INSERT INTO FileList (Name,Date,Size) VALUES (@Name,@Date,@Size)&#8221;<br \/>\n\u3000\u306b\u3066\u3001\u5b9f\u884c\u3059\u308bSQL\u6587\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u30dd\u30a4\u30f3\u30c8\u306fVALUES\u306e\u4e2d\u8eab\u3067\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(&#8220;@Name&#8221;, SqlDbType.NVarChar).Value = &#8220;\u540d\u79f0&#8221;<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<\/p>\n<p>\u5c11\u3057\u9762\u5012\u3067\u3059\u304c\u3001\u7701\u7565\u3057\u306a\u3044\u3068\u3053\u3093\u306a\u611f\u3058\u3067\u66f8\u304f\u306e\u304c\u6b63\u89e3\u3089\u3057\u3044\u3002<br \/>\n\u3000Dim param As System.Data.SqlClient.SqlParameter<br \/>\n\u3000param = command.CreateParameter()<br \/>\n\u3000param.Direction = ParameterDirection.Input<br \/>\n\u3000param.ParameterName = &#8220;@Name&#8221;<br \/>\n\u3000param.SqlDbType = SqlDbType.NVarChar<br \/>\n\u3000param.Value = &#8220;\u540d\u79f0&#8221;<br \/>\n\u3000command.Parameters.Add(param)<\/p>\n<p>SQL\u6587\u306b\u5024\u3092\u66f8\u304d\u8fbc\u307e\u305a\u3001\u3053\u306e\u69d8\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u5909\u6570\u3092\u4ecb\u3059\u3053\u3068\u3067\u3001SQL\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u3092\u9632\u3052\u308b\u3089\u3057\u3044\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL\u3067\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\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\u3078\u8ffd\u52a0 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-94","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\/94","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=94"}],"version-history":[{"count":6,"href":"https:\/\/r-side.net\/index.php?rest_route=\/wp\/v2\/posts\/94\/revisions"}],"predecessor-version":[{"id":145,"href":"https:\/\/r-side.net\/index.php?rest_route=\/wp\/v2\/posts\/94\/revisions\/145"}],"wp:attachment":[{"href":"https:\/\/r-side.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/r-side.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/r-side.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}