ADO.NET Provider for ServiceNow

Build 23.0.8839

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 { <column_reference> = <expression> } [ , ... ] WHERE { sys_id = <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 = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyClientId;OAuthClientSecret=MyClientSecret;User=MyUser;Password=MyPassword;Url=https://MyInstance12345.service-now.com/;";
using (ServiceNowConnection connection = new ServiceNowConnection(connectionString)) {
  int rowsAffected;
  ServiceNowCommand cmd = new ServiceNowCommand("UPDATE incident SET priority='4' WHERE sys_id = @mysys_id", connection);
  cmd.Parameters.Add(new ServiceNowParameter("mysys_id","S"));
  rowsAffected = cmd.ExecuteNonQuery();
}

VB.NET

Dim connectionString As [String] = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyClientId;OAuthClientSecret=MyClientSecret;User=MyUser;Password=MyPassword;Url=https://MyInstance12345.service-now.com/;"
Using connection As New ServiceNowConnection(connectionString)
  Dim rowsAffected As Integer
  Dim cmd As New ServiceNowCommand("UPDATE incident SET priority='4' WHERE sys_id = @mysys_id", connection)
  cmd.Parameters.Add(New ServiceNowParameter("mysys_id", "S"))
  rowsAffected = cmd.ExecuteNonQuery()
End Using

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