2010-08-10

Avoid EndOfLine at end of SQL with REAL Server 2009

Drove me nuts, but I discovered the cause of Error 21 "Not an Error" when using REAL Server 2009:
Adding a line terminator at the end of my SQL string.

This line does NOT trigger Error 21:
dim sql as String = "CREATE TABLE " + tableName + "( fld_text1 TEXT, " + EndOfLine + "fld_text2 TEXT);"

This line DOES trigger Error 21:
dim sql as String = "CREATE TABLE " + tableName + "( fld_text1 TEXT, " + EndOfLine + "fld_text2 TEXT);" + EndOfLine

It's that extra "+ EndOfLine" at the end that causes the problem.

I tried all 3 EndOfLine (Mac/CR, Win/CRLF, Unix/LF). Same behavior in all cases -- terminator on the end causes line 21.

Also, Error 21 is documented as "Library used incorrectly" but at runtime the Database.ErrorMessage is actually "Not an error".

No comments:

Post a Comment