I want to execute as ADO commandtype asCmdText as follows:
>WITH THIS
> psString = IIF(EMPTY(psString),'Nothing',psString)
>
> loSQLCmd = CREATEOBJECT("adodb.command")
> IF !.mbError
> loSQLCmd.ActiveConnection = .moConnection
> loSQLCmd.commandtype = 1 &&adCmdText
> ENDIF
>
> lcName = .name
> lcErrType = 'Sally'
>
> lsCmd = 'INSERT lmerrlog(er_date, er_type, er_object, er_desc) VALUES (GETDATE(), "' + lcErrType + '", "' + lcName + '", "' + psString +'")'
> loSQLCmd.commandtext = lsCmd
> loSQLCmd.execute()
>
>ENDWITH
This returns an OLE Dispatch error as follows:
> -- CONN ERRORS ----------------
> DESCRIPT: [Microsoft][ODBC SQL Server Driver][SQL Server]The name 'Sally' is illegal in this context. Only constants, constant expressions, or variables allowed here. Column names are illegal.
> NUMBER: ****
> SOURCE: Microsoft OLE DB Provider for ODBC Drivers
> SQLSTATE: 37000
> NATIVE: 128
I am fairly new to ADO, and I know that I may have the option of using the .addnew property. But I am quite determined to find out why this does not work.
Thanks, Bob
Database Development Team