EnquoteNCharLiteral(literal)
This method adds single quotes if required, prefixes an N
, and returns the result.
Declaration
// C# public static string EnquoteNCharLiteral(string literal);
Parameters
-
literal
The input literal.
Return Value
The literal is returned with single quotes prefixed with an N
.
Exceptions
ArgumentNullException - Value cannot be null. (Parameter 'identifier'
)
OracleException - Invalid identifier or literal.
Remarks
This method's purpose is to prevent SQL injection.
Any single quote in the literal is replaced with two single quotes for the purposes of escaping, or overloading. For example, the input string, scott's
, becomes N'scott''s'
in the return value.
Empty literals are allowed.
Leading and trailing white space is not ignored nor trimmed when quoted.
If validation using the database character set is required, then use the other EnquoteLiteral
overload.