使用ODBC备份Sqlserver数据库失败

软件原来是使用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

原文链接: https://www.cnblogs.com/nkzhangkun/p/8011206.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    使用ODBC备份Sqlserver数据库失败

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/265052

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月14日 下午4:57
下一篇 2023年2月14日 下午4:58

相关推荐