Using execute to manipulate the database

Source: Internet
Author: User

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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.