大家好,又见面了,我是你们的朋友全栈君。
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
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/143454.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...