ADO.NET Provider for ServiceNow

Build 25.0.9434

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 { 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 = "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] = "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) 2025 CData Software, Inc. - All rights reserved.
Build 25.0.9434