When using the MFC class CDatabase to connect to a data source, is there any way to execute SQL statements without having to open a CRecordSet object? I ask because CRecordSet::Open() appears to throw an exception when I use it to call stored procedures that don't return anything - and there's no reason to expect results from, say, sp_
delete_
row.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I use CDatabase::ExecuteSQL()
CDatabase database;
//database is connected somewhere
database.ExecuteSql("Drop table [users]"); // sql statement from little Johnny Drop tables
回答2:
You can execute a CCommand directly to perform a scalar query.