SqlResult.SqlCode Property
.NET Standard 2.x
Gets the success or failure code of the most recent SQL operation.
Namespace: PowerScript.Bridge
Assembly: PowerScript.Bridge.dll
Syntax
public int SqlCode { get; }
Property Value
int
The success or failure code of the most recent SQL operation.
Examples
The following code example executes a SQL statement and returns the result set. The state code of the result set is stored in the SqlCode
property of the SqlResult
object.
using System;
using PowerScript.Bridge;
namespace Appeon.ApiDoc.SqlResultExamples
{
public class SqlCodeExample
{
private readonly SchoolContext _context;
public SqlCodeExample(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 ExecuteNonQuery to execute the Update statement and stores the result in the SqlResult object
_context.SqlExecutor.ExecuteNonQuery(sql, out SqlResult sqlResult, name);
// Shows the value of SqlCode property of SqlResult object.
Console.WriteLine($"SqlCode = {sqlResult.SqlCode}");
/*This code produces the following output:
SqlCode = 0
*/
}
}
}
Applies to
.NET Standard
2.x