DELETE Statements
To delete information from a table, use DELETE statements.
DELETE Syntax
The DELETE statement requires the table name in the FROM clause and the row's primary key in the WHERE clause, as shown in the following example:
<delete_statement> ::= DELETE FROM <table_name> WHERE { TradingAccountUUID = <expression> } [ { AND | OR } ... ]
<expression> ::=
| @ <parameter>
| ?
| <literal>
You can use the ExecuteNonQuery method to execute data manipulation commands and retrieve the number of affected rows, as shown in the following example:
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