ADO.NET Provider for Sage 50 UK

Build 24.0.9062

DELETE ステートメント

テーブルから情報を削除するには、DELETE ステートメントを使用します。

DELETE 構文

DELETE ステートメントには、次の例に示すように、FROM 句のテーブル名とWHERE 句の行の主キーが必要です。

<delete_statement> ::= DELETE FROM <table_name> WHERE { TradingAccountUUID = <expression> } [ { AND | OR } ... ]

<expression> ::=
  | @ <parameter> 
  | ?
  | <literal>

次の例に示すように、ExecuteNonQuery メソッドを使って、データ操作コマンドを実行し影響を受ける行数を取得できます。

C#

String connectionString = "URL=http://localhost:5493/sdata/accounts50/GCRM/{C4C863BE-B098-4A7D-A78B-D7A92B8ADB59};User=Manager;Password=xxxxxx;";
using (Sage50UKConnection connection = new Sage50UKConnection(connectionString)) {
  int rowsAffected;
  Sage50UKCommand cmd = new Sage50UKCommand("DELETE FROM TradingAccounts WHERE TradingAccountUUID = @myTradingAccountUUID", connection);
  cmd.Parameters.Add(new Sage50UKParameter("myTradingAccountUUID","c2ef66a5-a545-413b-9312-79a53caadbc4"));
  rowsAffected = cmd.ExecuteNonQuery();
}

VB.NET

  
Dim connectionString As [String] = "URL=http://localhost:5493/sdata/accounts50/GCRM/{C4C863BE-B098-4A7D-A78B-D7A92B8ADB59};User=Manager;Password=xxxxxx;"
Using connection As New Sage50UKConnection(connectionString)
  Dim rowsAffected As Integer
  Dim cmd As New Sage50UKCommand("DELETE FROM TradingAccounts WHERE TradingAccountUUID = @myTradingAccountUUID", connection)
  cmd.Parameters.Add(New Sage50UKParameter("myTradingAccountUUID", "c2ef66a5-a545-413b-9312-79a53caadbc4"))
  rowsAffected = cmd.ExecuteNonQuery()
End Using

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