VC++碰到一个问题,谁能帮忙下啊
发表在C语言图书答疑 2012-10-08
是否精华
版块置顶:
 m_list_jh.SetExtendedStyle(LVS_EX_FLATSB
            |LVS_EX_FULLROWSELECT
            |LVS_EX_HEADERDRAGDROP
            |LVS_EX_ONECLICKACTIVATE
            |LVS_EX_GRIDLINES);
      m_list_jh.InsertColumn(0,"编号",LVCFMT_LEFT,110,0);
     m_list_jh.InsertColumn(1,"姓名",LVCFMT_LEFT,110,1);
     m_list_jh.InsertColumn(2,"性别",LVCFMT_LEFT,110,2);
    m_list_jh.InsertColumn(3,"学历",LVCFMT_LEFT,110,3);
      try
      {
            //创建连接对象实例
            m_pConnection.CreateInstance("ADODB.Connection");
            //设置连接字符串
            CString strConnect="DRIVER={Microsoft Access Driver (*.mdb)};\
                  uid=;pwd=;DBQ=jx.mdb;";
            //使用Open方法连接数据库
            m_pConnection->Open((_bstr_t)strConnect,"","",adModeUnknown);
      }
      catch(_com_error e)
      {
            AfxMessageBox(e.Description());
      }
      //设置查询字符串
      _bstr_t bstrSQL = "select * from employees order by 编号 desc";
      //创建记录集指针对象实例
      m_pRecordset.CreateInstance(__uuidof(Recordset));
      //打开记录集
      m_col->Open(bstrSQL,m_pConnection.GetInterfacePtr(),adOpenDynamic,
            adLockOptimistic,adCmdText);
      while(!m_col->adoEOF)
      {
            m_list_jh.InsertItem(0,"");
            m_list_jh.SetItemText(0,0,(char*)(_bstr_t)m_col->GetCollect("编号"));
            m_list_jh.SetItemText(0,1,(char*)(_bstr_t)m_col->GetCollect("姓名"));
            m_list_jh.SetItemText(0,2,(char*)(_bstr_t)m_col->GetCollect("性别"));
            m_list_jh.SetItemText(0,3,(char*)(_bstr_t)m_col->GetCollect("学历"));
            //将记录集指针移动到下一条记录
            m_pRecordset->MoveNext();
      }
      m_col->Close();
      m_pConnection->Close();
      return TRUE;  // return TRUE  unless you set the focus to a control
能帮我解答下,为什么我复制过来是错的

            m_pConnection是什么,需要怎么申明
分享到:
精彩评论 1
C语言
学分:0 LV1
TA的每日心情
无聊
2021-11-12 22:00:04
2012-10-10
沙发
m_pConnection是数据库连接智能指针,
看一下数据库连接入门的书就明白了。
首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照