ADO.NET Provider for Microsoft Exchange

Build 24.0.9062

UPDATE ステートメント

既存のレコードを変更するには、UPDATE ステートメントを使用します。

Update 構文

UPDATE 構文はカンマ区切りのカラムをインプットとして取り、SET 句のname-value ペアを新しいカラム値として取ります。

UPDATE <table_name> SET <select_statement> | {<column_reference> = <expression> [ , ... ]} WHERE { ItemId = <expression>  } [ { AND | OR } ... ] 

<expression> ::=
  | @ <parameter> 
  | ?
  | <literal>
ExecuteNonQuery メソッドを使って、データ操作コマンドを実行し影響を受けた行を取得できます。

C#

String connectionString = "User='[email protected]';Password='myPassword';Server='https://outlook.office365.com/EWS/Exchange.asmx';Platform='Exchange_Online';Schema='EWS';";
using (ExchangeConnection connection = new ExchangeConnection(connectionString)) {
  int rowsAffected;
  ExchangeCommand cmd = new ExchangeCommand("UPDATE Contacts SET GivenName='John' WHERE ItemId = @myItemId", connection);
  cmd.Parameters.Add(new ExchangeParameter("myItemId","AQMkAGRlMWQ5MDg0..."));
  rowsAffected = cmd.ExecuteNonQuery();
}

VB.NET

Dim connectionString As [String] = "User='[email protected]';Password='myPassword';Server='https://outlook.office365.com/EWS/Exchange.asmx';Platform='Exchange_Online';Schema='EWS';"
Using connection As New ExchangeConnection(connectionString)
  Dim rowsAffected As Integer
  Dim cmd As New ExchangeCommand("UPDATE Contacts SET GivenName='John' WHERE ItemId = @myItemId", connection)
  cmd.Parameters.Add(New ExchangeParameter("myItemId", "AQMkAGRlMWQ5MDg0..."))
  rowsAffected = cmd.ExecuteNonQuery()
End Using

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9062