| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2830 人关注过本帖
标题:ADO连接ACESS错误:IDispatch error #3149是什么意思?
只看楼主 加入收藏
vaqeteart
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-4-13
收藏
 问题点数:0 回复次数:0 
ADO连接ACESS错误:IDispatch error #3149是什么意思?
我编写的程序,ADO连接ACESS错误:IDispatch error #3149到底 什么意思?
大家请帮帮忙,谢谢

有兴趣的可以参见代码如下:
程序代码:
BOOL CQueryDlg::OnInitDialog() 
{
    CDialog::OnInitDialog();
    
    // TODO: Add extra initialization here
    CString strSql;//query command
    m_listbook.SetExtendedStyle (LVS_EX_TRACKSELECT|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);//有表格的显示
    m_listbook.InsertColumn (0,"商品码",LVCFMT_CENTER,70);
    m_listbook.InsertColumn (1,"类型",LVCFMT_CENTER,170);
    m_listbook.InsertColumn (2,"书名",LVCFMT_CENTER,60);
    m_listbook.InsertColumn (3,"作者",LVCFMT_CENTER,60);
    m_listbook.InsertColumn (4,"版本号",LVCFMT_CENTER,260);
    m_listbook.InsertColumn (5,"出版时间",LVCFMT_CENTER,70);
    m_listbook.InsertColumn (6,"出版社",LVCFMT_CENTER,170);
    m_listbook.InsertColumn (7,"库存数量",LVCFMT_CENTER,60);
    //m_listbook.InsertColumn (3,"卖出数量",LVCFMT_CENTER,60);
    m_listbook.InsertColumn (8,"打折",LVCFMT_CENTER,260);
    //m_listbook.InsertColumn (0,"进货日期",LVCFMT_CENTER,70);
    //m_listbook.InsertColumn (1,"卖出日期",LVCFMT_CENTER,170);
    //m_listbook.InsertColumn (2,"进货价格",LVCFMT_CENTER,60);
    m_listbook.InsertColumn (9,"销售价格",LVCFMT_CENTER,60);
    m_listbook.InsertColumn (10,"其他",LVCFMT_CENTER,260);
        
    //connect to the database
    try
    {
        if (!m_pConnection.CreateInstance(__uuidof(Connection)))
            m_pConnection->Open("Provider=Microsoft.JET.OLEDB.4.0;Data Source=.\data\sybsData.mdb","admin","admin",adModeUnknown);
    }
    
    catch (_com_error e)
    {
        CString errormessage;
        errormessage.Format ("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage ());
        AfxMessageBox (errormessage);
        return FALSE;
    }
    try
    {
        //determine the result set object
        m_pRecordset.CreateInstance(__uuidof(Recordset));
        strSql="SELECT * FROM bookInfo";
        //execute the sql command
        m_pRecordset->Open (_variant_t(strSql),m_pConnection.GetInterfacePtr (),
            adOpenStatic,adLockOptimistic,adCmdText);
        //_variant_t vName,vPsw;
        int nIndex=0;
        //read result record
        while (!m_pRecordset->adoEOF)
        {
            m_listbook.InsertItem (nIndex,(_bstr_t)(m_pRecordset->GetCollect ("商品码")));
            m_listbook.SetItemText (nIndex,1,(_bstr_t)(m_pRecordset->GetCollect ("类型")));
            m_listbook.SetItemText (nIndex,2,(_bstr_t)(m_pRecordset->GetCollect ("书名")));
            m_listbook.SetItemText (nIndex,3,(_bstr_t)(m_pRecordset->GetCollect ("作者")));
            m_listbook.SetItemText (nIndex,4,(_bstr_t)(m_pRecordset->GetCollect ("版本号")));
            m_listbook.SetItemText (nIndex,5,(_bstr_t)(m_pRecordset->GetCollect ("出版时间")));
            m_listbook.SetItemText (nIndex,6,(_bstr_t)(m_pRecordset->GetCollect ("出版社")));
            m_listbook.SetItemText (nIndex,7,(_bstr_t)(m_pRecordset->GetCollect ("库存数量")));
            //m_listbook.SetItemText (nIndex,4,(_bstr_t)(m_pRecordset->GetCollect ("卖出数量")));
            m_listbook.SetItemText (nIndex,8,(_bstr_t)(m_pRecordset->GetCollect ("打折")));
            //m_listbook.SetItemText (nIndex,2,(_bstr_t)(m_pRecordset->GetCollect ("进货日期")));
            //m_listbook.SetItemText (nIndex,3,(_bstr_t)(m_pRecordset->GetCollect ("卖出日期")));
            //m_listbook.SetItemText (nIndex,4,(_bstr_t)(m_pRecordset->GetCollect ("进货价格")));
            m_listbook.SetItemText (nIndex,9,(_bstr_t)(m_pRecordset->GetCollect ("销售价格")));
            m_listbook.SetItemText (nIndex,10,(_bstr_t)(m_pRecordset->GetCollect ("其他")));

            
            
            //m_listbook.InsertColumn (0,"商品码",LVCFMT_CENTER,70);
            //m_listbook.InsertColumn (1,"类型",LVCFMT_CENTER,170);
            //m_listbook.InsertColumn (2,"书名",LVCFMT_CENTER,60);
            //m_listbook.InsertColumn (3,"作者",LVCFMT_CENTER,60);
            //m_listbook.InsertColumn (4,"版本号",LVCFMT_CENTER,260);
            //m_listbook.InsertColumn (5,"出版时间",LVCFMT_CENTER,70);
            //m_listbook.InsertColumn (6,"出版社",LVCFMT_CENTER,170);
            //m_listbook.InsertColumn (7,"库存数量",LVCFMT_CENTER,60);
            ////m_listbook.InsertColumn (3,"卖出数量",LVCFMT_CENTER,60);
            //m_listbook.InsertColumn (8,"打折",LVCFMT_CENTER,260);
            ////m_listbook.InsertColumn (0,"进货日期",LVCFMT_CENTER,70);
            ////m_listbook.InsertColumn (1,"卖出日期",LVCFMT_CENTER,170);
            ////m_listbook.InsertColumn (2,"进货价格",LVCFMT_CENTER,60);
            //m_listbook.InsertColumn (9,"销售价格",LVCFMT_CENTER,60);
            //m_listbook.InsertColumn (10,"其他",LVCFMT_CENTER,260);

            nIndex++;
            m_pRecordset->MoveNext ();
        }
        m_pRecordset->Close ();
    }
    catch (_com_error e)
    {
        CString errormessage;
        errormessage.Format ("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage ());
        AfxMessageBox (errormessage);
        return FALSE;
    }/**/



    return TRUE;  // return TRUE unless you set the focus to a control
                  // EXCEPTION: OCX Property Pages should return FALSE
}
搜索更多相关主题的帖子: ADO ACESS IDispatch 
2008-07-29 16:47
快速回复:ADO连接ACESS错误:IDispatch error #3149是什么意思?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025196 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved