The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

Session.ExecuteNonQuery(String, Object[]) Method

Executes the specified SQL statement and returns the number of rows affected.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.2.dll

Declaration

public int ExecuteNonQuery(
    string sql,
    object[] parameterValues
)
Public Function ExecuteNonQuery(
    sql As String,
    parameterValues As Object()
) As Integer
public int ExecuteNonQuery(
    string sql,
    object[] parameterValues
)
Public Function ExecuteNonQuery(
    sql As String,
    parameterValues As Object()
) As Integer

Parameters

Name Type Description
sql String

A String value that specifies a parameterized SQL query.

parameterValues Object[]

An array of objects specifying parameters to pass to the database server along with the query.

Parameters

Name Type Description
sql String

A String value that specifies a parameterized SQL query.

parameterValues Object[]

An array of objects specifying parameters to pass to the database server along with the query.

Returns

Type Description
Int32

The number of rows affected by the executed SQL statement.

Returns

Type Description
Int32

The number of rows affected by the executed SQL statement.

Remarks

Use ExecuteNonQuery to execute SQL statements that do not produce result sets, such as UPDATE, INSERT, and DELETE statements.

The example below demonstrates how to use this method. Here, session is the Session instance.

using DevExpress.Xpo;
// ...
public void UpdateOrderDetails() {
    const string queryString = 
        @"UPDATE [Northwind].[dbo].[Order Details] 
        SET [Discount] = @p1 WHERE [UnitPrice] > @p2";
    int rowsAffected = session.ExecuteNonQuery(queryString, new object[] { 0.15, 100 });
}

Note that a format of parameter names in a SQL statement depends on the ADO.NET provider and database you use.

To learn more about executing SQL statements in XPO, refer to Direct SQL Queries.

Note

The ExecuteNonQuery method sends statements directly, so the correct statement syntax depends on a particular database server.

See Also