Code: Select all
nStatus:=ACE2.AdsOpenTable101(hConn,cDbfFullPath,hTable) // ACE.AE_SUCCESS
If nStatus==0
nStatus := ACE.AdsCreateSQLStatement(hConn, hStmt) // ACE.AE_SUCCESS
If nStatus=0
nStatus := ACE2.AdsExecuteSQLDirectW( hStmt, cSQLStatement, hPtr)
If nStatus<>0
pBuf := Char[]{256}
nLastError:=ACE.AdsGetLastError(pError, pBuf,pBufLen)
.....
https://devzone.advantagedatabase.com/d ... _error.htm
Problem: The problem might be caused by an SQL statement error or some other limitation in the way Advantage processes SQL statements.
Solution: Use AdsGetLastError to retrieve a detailed description of the error.
So I checked ADSGetLastError and this was 0, which is the same result as trying the query from within the Advantage Data Architect, which worked. Incorrectly, my program hence didn't return a successful addition and the record was being added every time again.
Now the weird thing. When I lookup the return value from AdsCreateSQLStatement in the help it says:
After the SQL statement has been executed a cursor handle will be returned. This cursor handle provides access to the rowset returned.
Now I first can't imagine that I have interpreted the return value to be 0 on success without a good reason and second, it most statements return 0 and the faulty one 7200 which doesn't look to me like a cursor but it does look like the ADS error code.
In short: I wonder how I can determine for sure that an AdsCreateSQLStatement actually added a record in DBF. For now i keep checking the return value: if this is 0 or it is non zero but GetLastError is 0 then I consider the record added successfully.
But is this the best way?
Dick