CDatabase::ExecuteSQL()

CDatabase::ExecuteSQL

Call this member function whenyou need to execute a SQL command directly.

当你要直接执行SQL命令的时候就访问这个成员函数

void ExecuteSQL(

  LPCTSTR lpszSQL 

);


lpszSQL

Pointer to anull-terminated string containing a valid SQL command to execute. You can passa CString.

一个指向以null结尾的string指针,string字符串包含一个可执行SQL命令。你可以直接传递一个Cstring

Remarks


Create the commandas a null-terminated string. ExecuteSQL does not return data records. Ifyou want to operate on records, use a recordset object instead.

将命令创建长null-terminated结尾的string。函数不返回数据集。如果你想操作数据集,请改用recordset对象。

Most of yourcommands for a data source are issued through recordset objects, which supportcommands for selecting data, inserting new records, deleting records, andediting records. However, not all ODBC functionality is directly supported bythe database classes, so you may at times need to make a direct SQL call with ExecuteSQL.

大多数关于数据源的命令是通过recordset对象发布的,它支持选择数据源,插入新的记录,删除记录以及编辑记录。然而,并不是所有的ODBC功能都被database类直接支持,所以有时候你需要用ExecuteSQL成员函数来直接访问SQL。

Example


try

  {

     m_dbCust.ExecuteSQL(

        _T("UPDATE Taxes")

           _T("SET Rate ='36' ")

           _T("WHERE Name= 'Federal'"));

  }

  catch(CDBException* pe)

  {

     // The error code isin pe->m_nRetCode

 

     pe->ReportError();

     pe->Delete();

  }

 

 

try

{

  m_dbCust.ExecuteSQL(

     _T("UPDATE Taxes ")

        _T("SET Rate = '36' ")

         _T("WHERE Name = 'Federal'"));

}

catch(CDBException* pe)

{

   //The error code is in pe->m_nRetCode

  pe->ReportError();

  pe->Delete();

}

 

Requirements


Header: afxdb.h

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值