SqlExecutorExtensions.ExecuteNonQuery(string sqlText, out SqlResult resultSet, params object[] parameters) Method
.NET Standard 2.x
Executes a stored procedure which returns no result set.
Namespace: PowerScript.Bridge
Assembly: PowerScript.Bridge.dll
Syntax
public static void ExecuteNonQuery(this ISqlExecutor sqlExecutor, string sqlText, out SqlResult resultSet, params object[] parameters)
Parameters
sqlText
System.String
The SQL statement which executes the stored procedure.
resultSet
PowerScript.Bridge.SqlResult
The result of the execution.
parameters
System.Object[]
(Optional) The parameters for executing the SQL stored procedure.
One or more ParamValue objects, containing the parameter direction and values, which correspond to the SQL stored procedure's parameters. See ParamValue for more info.
Examples
The following code example demonstrates how to use the ExecuteNonQuery
method to execute an Update statement which updates the Name field in the Department table.
using System;
using PowerScript.Bridge;
namespace Appeon.ApiDoc.ISqlExecutorExtensionsExamples
{
public class ExecuteNonQueryExample
{
private readonly SchoolContext _context;
public ExecuteNonQueryExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example()
{
// Defines a SQL statement which updates the Name field in the Department table.
string sql = "UPDATE Department SET Name = @name where DepartmentID = 1";
// Defines the parameter for the SQL statement.
string name = "Department name";
// Calls the ExecuteNonQuery method to execute the Update statement.
_context.SqlExecutor.ExecuteNonQuery(sql, out SqlResult sqlResult, name);
// Shows the number of affected rows.
Console.WriteLine($"AffectedCount = {sqlResult.AffectedCount}");
/*This code produces the following output:
AffectedCount = 1
*/
}
}
}
Applies to
.NET Standard
2.x