NOP Design Home Page
Documentation
TOC/Index
Search
Downloads



SqlEncode

Encodes a string for use in an SQL query

SqlEncode escapes unwanted characters appropriately for various database platforms. You must specify one of the support database types to escape for, either "PgSQL", "MySQL", "MsSQL" or "SQL92"

PgSQL:

  • Single quote (') becomes ('')
  • Backslash (\) becomes (\\)

    MySQL:

  • Single quote (') becomes (\')
  • Backslash (\) becomes (\\)
  • Quote (") becomes (\")

    MsSQL:

  • Single quote (') becomes ('')

    SQL92:

  • Single quote (') becomes ('')

    Sample Source

    strMyValue := """This is a value with "quotes", 'single quotes', and \ backslash \ characters."""
    
    Say SqlEncode strMyValue For "PgSQL"
    Say "\n\n"
    Say SqlEncode strMyValue For "MySQL"
    Say "\n\n"
    Say SqlEncode strMyValue For "MsSQL"
    Say "\n\n"
    Say SqlEncode strMyValue For "SQL92"
    Say "\n\n"
    
    
    
    

    Related Function(s):
       GetRowset; PrepareRowset; PrepareStatement;

    Minimum version: 4.8 build 20050831