UPDATE ステートメント
既存のレコードを変更するには、UPDATE ステートメントを使用します。
Update 構文
UPDATE 構文はカンマ区切りのカラムをインプットとして取り、SET 句のname-value ペアを新しいカラム値として取ります。
UPDATE <table_name> SET <select_statement> | {<column_reference> = <expression> [ , ... ]} WHERE { Id = <expression> } [ { AND | OR } ... ]
<expression> ::=
| @ <parameter>
| ?
| <literal>
ExecuteNonQuery メソッドを使って、データ操作コマンドを実行し影響を受けた行を取得できます。
C#
String connectionString = "Url=http://localhost:50000/b1s/v1;User=username;Password=password;CompanyDB=dbname;"; using (SAPBusinessOneConnection connection = new SAPBusinessOneConnection(connectionString)) { int rowsAffected; SAPBusinessOneCommand cmd = new SAPBusinessOneCommand("UPDATE Orders SET DocType='dDocument_Items' WHERE Id = @myId", connection); cmd.Parameters.Add(new SAPBusinessOneParameter("myId","22")); rowsAffected = cmd.ExecuteNonQuery(); }
VB.NET
Dim connectionString As [String] = "Url=http://localhost:50000/b1s/v1;User=username;Password=password;CompanyDB=dbname;" Using connection As New SAPBusinessOneConnection(connectionString) Dim rowsAffected As Integer Dim cmd As New SAPBusinessOneCommand("UPDATE Orders SET DocType='dDocument_Items' WHERE Id = @myId", connection) cmd.Parameters.Add(New SAPBusinessOneParameter("myId", "22")) rowsAffected = cmd.ExecuteNonQuery() End Using