>>>>>>>cSqlUpdate = "update mytable set field1 = ?" + cNewFld1Val + ", field2 = ?" + cNewFld2Val + " where pk = 10" >>>>>>>lnResult = SQLEXEC( nSqlHandle, cSqlUpdate) >>>>>>>>>>>>>>I get a prompt to enter a value (as if I didn't specify the values cNewFld1Val or cNewFld2Val.
>>>>>>cSqlUpdate = "update mytable set field1 = ?cNewFld1Val , field2 = ?cNewFld2Val where pk = 10" >>>>>>lnResult = SQLEXEC( nSqlHandle, cSqlUpdate)>>>>>
LOCAL cNewFld1Val, cNewFld2Val cNewFld1Val = "Value1" cNewFld2Val = "Value2" cSqlUpdate = "update mytable set field1 = ?cNewFld1Val , field2 = ?cNewFld2Val where pk = 10" lnResult = SQLEXEC( nSqlHandle, cSqlUpdate)However, I advise you to wrap the sqlExec into a class, because that gives you a lot of possibilities to do proper error handling and lots of other needful functionality, including logging, messaging etc. For that purpose then the variables must be declared as Private, because they get handed down to the method:
LOCAL loSQLQuery AS SQLQuery OF DataHandler.vcx loSQLQuery = NewObject("SQLQuery","DataHandler.vcx") PRIVATE cNewFld1Val, cNewFld2Val cNewFld1Val = "Value1" cNewFld2Val = "Value2" cSqlUpdate = "update mytable set field1 = ?cNewFld1Val , field2 = ?cNewFld2Val where pk = 10" loSQLQuery.ExecuteNonQuery(cSqlUpdate) ?loSQLQuery.Success ?loSQLQuery.ErrorNr ?loSQLQuery.ErrorMessage ?loSQLQuery.nSqlHandle
Class SQLQuery: PROCEDURE ExecuteNonQuery(queryString) LOCAL lRetVal lRetVal = SQLEXEC( THIS.nSqlHandle, queryString) > 0 IF !m.lRetVal LOCAL ARRAY laError[1] AERROR(laError) THIS.ErrorNr = laError[1] THIS.ErrorMessage = laError[3] ENDIF RETURN m.lRetVal <PRE>