UPDATE Statements
To modify existing records, use UPDATE statements.
Update Syntax
The UPDATE statement takes as input a comma-separated list of columns and new column values as name-value pairs in the SET clause, as shown in the following example:
UPDATE <table_name> SET <select_statement> | {<column_reference> = <expression> [ , ... ]} WHERE { TradingAccountUUID = <expression> } [ { AND | OR } ... ]
<expression> ::=
| @ <parameter>
| ?
| <literal>
You can use the ExecuteNonQuery method to execute data manipulation commands and retrieve the rows affected, 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("UPDATE TradingAccounts SET Name='Smith' 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("UPDATE TradingAccounts SET Name='Smith' WHERE TradingAccountUUID = @myTradingAccountUUID", connection) cmd.Parameters.Add(New Sage50UKParameter("myTradingAccountUUID", "c2ef66a5-a545-413b-9312-79a53caadbc4")) rowsAffected = cmd.ExecuteNonQuery() End Using