DbResultSet.SqlCode Property
.NET Standard 2.x
Gets the return code of the SQL operation.
Namespace: PowerScript.Bridge
Assembly: PowerScript.Bridge.dll
Syntax
public virtual int SqlCode => _sqlCode;
Property Value
System.Int32
The success or failure code of the most recent SQL operation.
0
- Success.
100
- Fetched row not found.
-1
- Error. Use SQLErrText or SQLDBCode to obtain the details.
Examples
The following code example executes a stored procedure and returns the result set. The state code of the result set is stored in the SqlCode
property of the DbResultSet
object.
using System;
using SnapObjects.Data;
using PowerScript.Bridge;
namespace Appeon.ApiDoc.DbResultSetExamples
{
public class SqlCodeExample
{
private readonly SchoolContext _context;
public SqlCodeExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example()
{
int studentID = 2;
// Executes a stored procedure which gets the data of StudentGrade table according to StudentID
_context.SqlExecutor.ExecuteProcedure("GetStudentGrades",
out DbResultSet resultSet, ParamValue.New<int>("StudentID", studentID));
// Shows the code of the execution result. 0 -- succeeds; 100 -- no result set; -1 -- execution error
Console.WriteLine($"SqlCode = {resultSet.SqlCode}");
/*This code produces the following output:
SqlCode = 0
*/
}
}
}
Applies to
.NET Standard
2.x