ADO.NETで、接続したDBに対してステートメント(SQL コマンド)を実行する方法を説明します。
ExecuteNonQueryの実行
Dim builder As SqlConnectionStringBuilder = New SqlConnectionStringBuilder() builder.DataSource = ".\SQLEXPRESS" builder.AttachDBFilename = "D:\DB\TestDB.mdf" builder.IntegratedSecurity = True builder.UserInstance = True builder.MultipleActiveResultSets = True Dim ConnectString As String = builder.ToString() Using sqlConnect As New SqlConnection(ConnectString) sqlConnect.Open() Dim command As SqlCommand = sqlConnect.CreateCommand() Try command.CommandText = "UPDATE Table_1 SET Item2 = 'A0001'" command.ExecuteNonQuery() Catch ex As Exception End Try End Using