i have a simple method to insert records into any table and any database depending on parameters passed.
LPARAMETERS lcDatabase, lcTable, lcFields, lcValues
lnReturn = 0
Use In Select(lcTable)
If This.m_open_database(lcDatabase,.F.) &&& make sure database is open and available
Use &lcDatabase!&lcTable In 0 Again Shared
INSERT INTO &lcTable ;
(&lcFields);
VALUES ;
(&lcValues)
lnReturn = &lcTable..pk
ENDIF
Use In Select(lcTable)
This.m_close_database(.F.)
RETURN lnReturn
and works find except when i have a memo field and the value contains a carriage return line feed.
if the memo field is 'note' and the value to to insert is
lcNote = 'Some text line 1'+chr(10)+chr(13)+'second line'
and i do a insert like
Insert into cTable (fk_category, note) values (715, lcNote)
this works fine
However in the method above i would pass in the parameters
lcDatabaseName ' SomeDatabase'
lcTable = 'cTable'
lcFields= 'fk_category,Note'
lcValues = alltrim(str(715))+','+lcNote
the method will fail. if the lcNote does not contain the carriage return - line feed everything is okay.
what am i missing?
Thanks in advance