>>INSERT INTO EMAILHIS (STR_FIELD) VALUES (?cStr2Insert) >>>>I checked the cStr2Insert is in scope and has a simple value (without even chr(13) and chr(10).) And I get error "Syntax error". I don't understand why.
>>SQLEXEC(nSqlHandle,cSqlInsert)
>>
>>But what am I doing wrong with the VFP table insert?>CREATE CURSOR TestCursor (TestColumn Varchar(50)) > >LOCAL SQLStatement AS String >LOCAL SQLParameter AS String >LOCAL TrapError AS Exception > >m.SQLParameter = "line 1" + CHR(13) + CHR(10) + "line 2" > >TRY > INSERT INTO TestCursor (TestColumn) VALUES (?m.SQLParameter) >CATCH TO m.TrapError > MESSAGEBOX("Parameter not allowed in INSERT. Reverting to simple variable reference." + ; > CHR(13) + "Error message: " + m.TrapError.Message, 48) > INSERT INTO TestCursor (TestColumn) VALUES (m.SQLParameter) >ENDTRY > >TRY > SELECT * FROM TestCursor WHERE TestColumn = ?m.SQLParameter >CATCH TO m.TrapError > MESSAGEBOX("Parameter not allowed in SELECT. Reverting to simple variable reference." + ; > CHR(13) + "Error message: " + m.TrapError.Message, 48) > SELECT * FROM TestCursor WHERE TestColumn = ?m.SQLParameter >ENDTRY > >TRY > UPDATE TestCursor SET TestColumn = ?m.SQLParameter >CATCH TO m.TrapError > MESSAGEBOX("Parameter not allowed in UPDATE SET clause. Reverting to simple variable reference." + ; > CHR(13) + "Error message: " + m.TrapError.Message, 48) > UPDATE TestCursor SET TestColumn = m.SQLParameter >ENDTRY > >TRY > UPDATE TestCursor SET TestColumn = m.SQLParameter WHERE TestColumn = ?m.SQLParameter >CATCH TO m.TrapError > MESSAGEBOX("Parameter not allowed in UPDATE WHERE clause. Reverting to simple variable reference." + ; > CHR(13) + "Error message: " + m.TrapError.Message, 48) > UPDATE TestCursor SET TestColumn = m.SQLParameter WHERE TestColumn = m.SQLParameter >ENDTRY >>
" <CR> "
which eliminated the error message. And since - in this particular case - the content of the string that goes into the VFP table field is not super important it will do. Also, I am trying to convert as many customers as possible to using SQL Server as the database. There are many benefits of SQL server vs VFP data. And since my customers rarely have large databases, the SQL Server Express (free) works well.