当前位置:Gxlcms > 数据库问题 > 使用ODBC备份Sqlserver数据库失败

使用ODBC备份Sqlserver数据库失败

时间:2021-07-01 10:21:17 帮助过:13人阅读

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

使用ODBC备份Sqlserver数据库失败

标签:return   not   lex   design   ext   执行   handle   backup   first   

人气教程排行