当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: 在Visual C++中用ADO进行数据库编程(中) 4.执行SQL命令并取得结果记录集 为了取得结果记录集,我们定义一个指向Recordset对象的指针:_RecordsetPtr m_pRecordset;并为其创建Recordset对象的实例: m_pRecordset.CreateIn...
 

 

 ·using ado from c++     »显示摘要«
    摘要:environment: visual c++ 6microsoft activex data object (ado) provides an easy way to data access and manipulation that is independent of data stores, tools, and languages. this flexibility and easy-to......
 ·ado操作数据的几个问题     »显示摘要«
    摘要:总结了几个在用ado操作数据库的时候常遇见的问题。1读数据库中的二进制数据,在论坛里有人提到用getchunk不行,只能读image类型的数据,下面是一个声音数据的例子:long ldatasize = m_adorecordset.getfields()->getitem("声音")->actualsize;if(ldatasize > 0){ _varia......


在Visual C++中用ADO进行数据库编程(中)

在visual c++中用ado进行数据库编程(中)          4.执行sql命令并取得结果记录集

  (1)利用connection对象的execute方法执行sql命令 【程序编程相关:利用VC制作动态连接库(.dll)(采用

      为了取得结果记录集,我们定义一个指向recordset对象的指针:_recordsetptr m_precordset;并为其创建recordset对象的实例: m_precordset.createinstance("adodb.recordset");sql命令的执行可以采用多种形式,下面我们一进行阐述. 【推荐阅读:DLL的向后兼容性问题

     _recordsetptr connection15::execute ( _bstr_t commandtext, variant * recordsaffected, long options ) 【扩展信息:利用VC制作动态连接库(.dll)(采用

  execute方法的原型如下所示:

     其中commandtext是命令字串,通常是sql命令. 参数recordsaffected是操作完成后所影响的行数,  参数options表示commandtext中内容的类型,options可以取如下值之一: adcmdtext:表明commandtext是文本命令 adcmdtable:表明commandtext是一个表名 adcmdproc:表明commandtext是一个存储过程 adcmdunknown:未知

    execute执行完后返回一个指向记录集的指针,下面我们给出具体代码并作说明.     _variant_t recordsaffected;    ///执行sql命令:create table创建表格users,users包含四个字段:整形id,字符串username,整形old,日期型birthday    m_pconnection->execute("create table users(id integer,username text,old integer,birthday datetime)",   &recordsaffected,   adcmdtext);

    ///往表格里面添加记录    m_pconnection->execute("insert into users(id,username,old,birthday) values (1, washington,25,1970/1/1)",&recordsaffected,adcmdtext);


...   下一页
    摘要:1.引入ado库文件   使用ado前必须在工程的stdafx.h文件里用直接引入符号#import引入ado库文件,以使编译器能正确编译。代码如下所示:  #import "c:\program files\common files\system\ado\msado15.dll"   no—namespaces rename("eof" ad......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE