标题:帮忙看一下这个基于MFC的对话框编程的一部分代码
只看楼主
hustzhangzhe
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-7-16
结帖率:0
已结贴  问题点数:20 回复次数:2 
帮忙看一下这个基于MFC的对话框编程的一部分代码
void CFdasfDlg::OnButton1()
{
    // TODO: Add your control notification handler code here
CString str;
    m_Dep.GetLBText(m_Dep.GetCurSel(),str);
    ADOConn m_ADOConn;
    m_ADOConn.OnInitADOConn();
    CString sql;
    sql.Format("select * from tb_phonebook where 所在部门 = '%s'",str);
    m_ADOConn.m_pRecordset = m_ADOConn.GetRecordSet((_bstr_t)sql);
    while(!m_ADOConn.m_pRecordset->adoEOF)
    {
        m_ID[m_Num]    = (char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("编号");
        m_Name[m_Num]  = (char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("姓名");
        m_Phone[m_Num] = (char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("电话号码");
        m_ADOConn.m_pRecordset->MoveNext();
        m_Num++;
    }
    i=0;
    while(m_Num>=i)
    {
    UpdateData(TRUE);


    CString sql;
    sql.Format("insert into tb_abc(bianhao,xingming,dianhua) values ('%s','%s','%s')",m_ID[i],m_Name[i],m_Phone[i]);
    m_ADOConn.ExecuteSQL((_bstr_t)sql);

i++;
    }
   
    sql.Format("select * from tb_abc");
    m_ADOConn.m_pRecordset = m_ADOConn.GetRecordSet((_bstr_t)sql);
ababababab bb;
        bb.m_Grid.InsertItem(i,"");
        while(!m_ADOConn.m_pRecordset->adoEOF)
    {bb.m_Grid.InsertItem(i,"");
    bb.m_Grid.SetItemText(i,0,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("bianhao"));
    bb.m_Grid.SetItemText(i,1,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("xingming"));
        bb.m_Grid.SetItemText(i,2,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("dianhua"));
        
        m_ADOConn.m_pRecordset->MoveNext();
        
        

    m_ADOConn.ExitConnect();
    CDialog::OnCancel();


    }

void CFdasfDlg::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
    // TODO: Add your control notification handler code here
    m_Num = 1;
    int pos = m_Gri.GetSelectionMark();
    m_ID[0]    = m_Gri.GetItemText(pos,0);
    m_Name[0]  = m_Gri.GetItemText(pos,1);
    m_Phone[0] = m_Gri.GetItemText(pos,5);
   

        UpdateData(TRUE);

    ADOConn m_ADOConn;
    m_ADOConn.OnInitADOConn();
    CString sql;
    sql.Format("insert into tb_abc(bianhao,xingming,dianhua) values ('%s','%s','%s')",m_ID[0],m_Name[0],m_Phone[0]);
    m_ADOConn.ExecuteSQL((_bstr_t)sql);


   


ababababab aa ;


    aa.m_Grid.InsertItem(0,"");
   
        aa.m_Grid.SetItemText(0,0,m_ID[0]);
aa.m_Grid.SetItemText(0,1,m_Name[0]);
    aa.m_Grid.SetItemText(0,2,m_Phone[0]);





        
   
}
搜索更多相关主题的帖子: sql 编程 control 对话框 where 
2011-07-16 19:33
hahayezhe
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:湖南张家界
等 级:贵宾
威 望:24
帖 子:1386
专家分:6999
注 册:2010-3-8
得分:20 
???问题呢
2011-07-17 11:39
hustzhangzhe
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-7-16
得分:0 
问题是,这段程序运行的时候弹出运行时错误啊
2011-07-17 17:14



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-345633-1-1.html




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

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