1. The prototype is: _connectionptr Execute (_bstr_t CommandText, VARIANT * RecordsAffected,
Long Options);
Parameters
1. CommandText is a command string, usually an SQL command, or it can be a table name, stored procedure, etc.
2. RecordsAffected Optional, is the number of rows affected after the operation is completed
3. Options to interpret the CommandText parameters, options can be CommandTypeEnum or ExecuteOptionEnum enumeration type values
Type
Description
Adcmdunspecifed=-1
CommandType attribute not described
Adcmdtext=1
Indicates that the provider should assign CommandText to the text definition of the command.
adCmdTableDirect
Indicates that the provider should return all rows from a table named CommandText.
adcmdtable=2
Indicates that the provider should assign the CommandText to the table name.
Adcmdstoredproc=4
Indicates that the provider should assign the CommandText to a stored procedure.
Adcmdunknown=8
Indicates that the command type in the CommandText parameter is unknown.
Adexecuteasync
Indicates that the command should execute asynchronously.
Adfetchasync
Indicates that the row after the initial number specified by the CacheSize property should be extracted asynchronously.
Define a variable variant_t RecordsAffected first;
String str;
Add Record:
//STR. Format ("Delete from Stuinfo where stuid=60213");
Str. Format ("INSERT INTO stuinfo values" (' Mencius ', 80203, ' Male ', 23, ' College of ', ' Hubei ', 68, ' 06 textbook 1 Classes ') ");
//M_pconnection->execute ((_bstr_t) str,null,adcmdtext);
M_pconnection->execute ((_bstr_t) str,&recordsaffected,adcmdtext);
Add a record through the dialog box:
variant_t RecordsAffected;
Strexec.format ("INSERT into stuinfo values ('%s ',%ld, '%s ',%d, '%s ', '%s ',%d, '%s ')", Dlg.m_stuname, (ATOL) (DLG.M_STUID) , Dlg.m_sex,
(atoi) (dlg.m_age), Dlg.m_dept,dlg.m_nativeplace, (atoi) (Dlg.m_score), dlg.m_class);
Delete Record:
Strexec.format ("Delete from Stuinfo where Stuid=%ld", (ATOL) (M_listctrl.getitemtext (iitem,0)));
Modify Record:
Strexec.format ("Update stuinfo set stuname= '%s ' where stuid=%d", Dlg.m_stuname, (ATOL) (Dlg.m_stuid));
M_pconnection->execute ((_bstr_t) strexec,&recordsaffected,adcmdtext);