软件原来是使用ADO访问LocalDB,现在切换为开源ODBC的C++封装nanodbc,
调试后其他一切正常,可BACKUP DATABASE命令虽然返回成功,但实际备份却没有成功,
查了下资料,在微软网站上发现一个回答
This is by design. Your application must call SQLMoreResults to ensure all the results of the statement are consumed and hence completed. BACKUP sends several messages back to the user to report progress and statistics, and SQLExecDirect returns when the first of these messages is returned. This does not mean the backup has fully completed though. Once SQLMoreResults returns SQL_NO_DATA, you can safely close the statement handle, as you've observed.
执行BACKUP命令后必须再调用SQLMoreResults,在nanodbc不能使用just_execute,需要使用execute且调用result::next_result