The software was originally using ADO to access LocalDB, now switched to open source ODBC C + + package Nanodbc,
Everything else is ok after debugging, but although the backup DATABASE command returns successfully, the actual backups are unsuccessful.
Checked the information and found an answer on the Microsoft website.
This was by design. Your application must call SQLMoreResults to ensure all the results of the statement is consumed and hence completed. BACKUP sends several messages back to the user-report progress and statistics, and SQLExecDirect returns when the first Of these messages is returned. This does isn't mean the backup has fully completed though. Once SQLMoreResults returns SQL_NO_DATA, you can safely close the statement handle, as you ve observed.
You must call SQLMoreResults after the backup command is executed, NANODBC cannot use Just_execute, you need to use Execute and call Result::next_result
Failed to back up SQL Server database using ODBC