With CDatabase, can I send SQL without using CReco

2019-08-18 08:26发布

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.

标签: c++ mfc odbc
2条回答
可以哭但决不认输i
2楼-- · 2019-08-18 09:01

I use CDatabase::ExecuteSQL()

CDatabase database;
//database is connected somewhere
database.ExecuteSql("Drop table [users]");  // sql statement from little Johnny Drop tables
查看更多
我想做一个坏孩纸
3楼-- · 2019-08-18 09:13

You can execute a CCommand directly to perform a scalar query.

查看更多
登录 后发表回答