// CAdodc m_adodc; classwizard generated class CAdodc, microsoft ado data control
m_adodc.SetRecordSource(_T("select * from table1 where intfield>20"));
m_adodc.Refresh();

解决方案 »

  1.   

    不行啊,编译时没错,但怎么一运行,一触发这个事件就报什么mfc420错误呢?然后就要关闭应用程序了,怎么回事呢?
      

  2.   

    have you changed the SQL language accordingly?
      

  3.   

    我是这样写的:
    CAdodc *p_Adodc=NULL;
    p_Adodc->SetRecordSource(_T("select * from dbo_S"));
    p_Adodc->Refresh();
    错在哪里?
      

  4.   

    Please insert microsoft ado data control to your dialog template, then add a member to your dialog class via classwizard(so classwizard can create a class wrapper for the control).
    you can create the datacontrol dynamically, but it is a bit complicated.
    before using a pointer, at least initialize it to a valid address.
    since CAdodc *p_Adodc=NULL;
    runtime error sure occurs at the line p_Adodc->SetRecordSource(_T("select * from dbo_S"));
      

  5.   

    I have already placed a ado data control on the dialog template,但您说add a member to my dialog是指什么member?那个runtime error 是不是就是由于指针初始化不当造成的?看来我还是不声明为指针比较好
      

  6.   

    CAdodc *p_Adodc=NULL;
    p_Adodc->SetRecordSource(_T("select * from dbo_S"));
    NULL->SetRecordSource(_T("select * from dbo_S"));  ????? p_Adodc->Refresh();
      

  7.   

    感谢!!
    但我后来已经改成:CAdodc m_adodc;
                m_adodc.SetRecordSource(_T("select * from dbo_S"));
       m_adodc.Refresh();
    可是还是报错啊
      

  8.   

    class CXXDlg:public CDialog
    {
    ...
    CAdodc m_adodc;//add this member via classwizard
    ...
    }void CXXDlg::Change()
    {
    m_adodc.SetRecordSource(_T("select * from dbo_S"));
       m_adodc.Refresh();}
      

  9.   

    我这有例程。http://jeffchen.myrice.com/StatService.zip
      

  10.   

    我的问题已经解决,多谢各位!!特别是masterz,您的via classwizard太重要了,现在看来我的问题的确有点……
    总之,多谢大家!散分了