DbResultSet.ErrorText Property
.NET Standard 2.x
Gets the error message when errors occur during the SQL operation.
Namespace: PowerScript.Bridge
Assembly: PowerScript.Bridge.dll
Syntax
public string ErrorText{get => _errorText; internal set => _errorText = value ?? String.Empty;}
Property Value
System.String
Returns the errors during the SQL operation.
Examples
The following code example demonstrates how to use the ErrorText
property to get the exception message.
using System;
using SnapObjects.Data;
using PowerScript.Bridge;
namespace Appeon.ApiDoc.DbResultSetExamples
{
public class ErrorTextExample
{
private readonly SchoolContext _context;
public ErrorTextExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example()
{
// The stored procedure to be executed requires an int-type parameter to be passed in.
// But actually a string-type parameter is passed in.
// This will cause an exception and the exception message will be stored
// in the ErrorText property of the DbResultSet object.
_context.SqlExecutor.ExecuteProcedure("GetStudentGrades",
out DbResultSet resultSet, ParamValue.New<string>("StudentID", "abc"));
// Shows the error text stored in the result set
Console.WriteLine($"ErrorText = {resultSet.ErrorText}");
/*This code produces the following output:
ErrorText = Error converting data type nvarchar to int.
*/
}
}
}
Applies to
.NET Standard
2.x