本人的程序是讲access中的数据定时传送到oracle中,策略是根据根据access中的数据的时间是否满足要求,满足的则传送,不满足,等下次再判断,再传送。结果老是出错,但是他又不是一运行就出错,我的程序是1分钟送一次数据,他每次就在运行了1小时左右才出错,我查看了一下windows的进程,发现内存也没有什么很大的变化,只有8M左右,到底是什么原因阿?
错误信息如下Runtime Error
Program:***
This application has requests the runtime to terminate it in an unusual way
.please contact the application's support team for more inforation
帮帮忙阿,如果大哥看不出问题的,我可以把代码发给你,麻烦解决一下阿

解决方案 »

  1.   

    int transflag=0;
    m_pConnection.CreateInstance(__uuidof(Connection));
    m_pConnectionServ.CreateInstance(__uuidof(Connection));

    GetDlgItem(IDC_INFO)->SetWindowText("连接数据库...");

    try                 
    {
    // 打开本地Access库spdb.mdb
    m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=变电站电力设备在线检测系统数据库.mdb","","",adModeUnknown);
    //Server
    //m_pConnectionServ->Open("Provider=MSDAORA;Persist Security Info=True;User ID=zhx;Password=zhx;Data Source=","","",-1);
    m_pConnectionServ->Open("Provider=OraOLEDB.Oracle.1;Persist Security Info=True;User ID=ztjx;Password=ztjxztjx;Data Source=hepztjx","","",-1);
    //("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=tempdb.mdb","","",adModeUnknown);

    }
    catch(_com_error e)
    {
    //AfxMessageBox("数据库连接失败!");
    GetDlgItem(IDC_INFO)->SetWindowText("数据库连接失败!正在重试...");
    return;


    m_pRecordset.CreateInstance(__uuidof(Recordset));
    m_pRecordsetServ.CreateInstance(__uuidof(Recordset));

    CTime dbTime(CTime::GetCurrentTime());
    CString time_start,time_end;
    time_end.Format("%d-%d-%d %d:%d:%d",dbTime.GetYear(),dbTime.GetMonth(),dbTime.GetDay(),dbTime.GetHour(),dbTime.GetMinute(),dbTime.GetSecond());
    int timetemp;
    timetemp=datenum;
    if(datetype==1)
    {
    time_start.Format("%d-%d-%d %d:%d:%d",dbTime.GetYear(),dbTime.GetMonth(),dbTime.GetDay(),dbTime.GetHour(),dbTime.GetMinute()-timetemp,dbTime.GetSecond());

    }

    if(datetype==2)
    {
    time_start.Format("%d-%d-%d %d:%d:%d",dbTime.GetYear(),dbTime.GetMonth(),dbTime.GetDay(),dbTime.GetHour()-timetemp,dbTime.GetMinute(),dbTime.GetSecond());

    }

    if(datetype==3)
    {

    time_start.Format("%d-%d-%d %d:%d:%d",dbTime.GetYear(),dbTime.GetMonth(),dbTime.GetDay()-timetemp,dbTime.GetHour(),dbTime.GetMinute(),dbTime.GetSecond());

    }

    try
    {//取所需要的数据
    //time_start="2002-8-30 11:00:00";
    //time_end="2002-8-30 12:00:00";

    CString strQuery;
    strQuery.Format("SELECT * FROM Data_MOA WHERE Time between #%s# AND #%s#",time_start,time_end);

    _bstr_t strConnect1 = strQuery;
    m_pRecordset->Open(strConnect1,   // 查询表中字段
    m_pConnection.GetInterfacePtr(),  // 获取库接库的IDispatch指针
    adOpenDynamic,
    adLockOptimistic,//传送最大
    adCmdText);

    }
    catch(_com_error *e)
    {
    TRACE(e->ErrorMessage());
    GetDlgItem(IDC_INFO)->SetWindowText("打开本地数据库MOA表失败!正在重试...");
    return;
    }

    try
    {//连接远程表
    _bstr_t strConnect = "SELECT * FROM Data_MOA";
    m_pRecordsetServ->Open(strConnect,   // 查询表中所有字段
    m_pConnectionServ.GetInterfacePtr(),  // 获取库接库的IDispatch指针
    adOpenDynamic,
    adLockOptimistic,
    adCmdText);
    }
    catch(_com_error *e)
    {
    TRACE(e->ErrorMessage());
    GetDlgItem(IDC_INFO)->SetWindowText("打开远程数据库表MOA失败!正在重试...");
    return;
    }

    while(!m_pRecordset->adoEOF)
    {//有符合条件的m_pRecordsetServ->GetCollect("AutoNumber")
    m_pRecordsetServ->AddNew();
    m_pRecordsetServ->PutCollect("AutoNumber", m_pRecordset->GetCollect("AutoNumber"));
    m_pRecordsetServ->PutCollect("Number",  m_pRecordset->GetCollect("Number"));
    m_pRecordsetServ->PutCollect("Phase", m_pRecordset->GetCollect("Phase"));
    m_pRecordsetServ->PutCollect("Time",m_pRecordset->GetCollect("Time"));
    m_pRecordsetServ->PutCollect("Leakage", m_pRecordset->GetCollect("Leakage"));
    m_pRecordsetServ->PutCollect("Resistor", m_pRecordset->GetCollect("Resistor"));
    m_pRecordsetServ->PutCollect("Voltage", m_pRecordset->GetCollect("Voltage"));
    m_pRecordsetServ->PutCollect("Temperature", m_pRecordset->GetCollect("Temperature"));
    m_pRecordsetServ->PutCollect("Humidity", m_pRecordset->GetCollect("Humidity"));

    m_pRecordsetServ->Update();
    m_pRecordset->MoveNext();
    transflag=1;
    }
    m_pRecordset->Close();
    m_pRecordsetServ->Close();
    m_pConnection->Close();
    m_pConnectionServ->Close();

    if(transflag==1)GetDlgItem(IDC_INFO)->SetWindowText("数据成功插入,准备下一次传送");

      

  2.   

    定时器代码如下:
    显示在一个函数中写调用定时器的代码void CDTDlgDlg::OnRun() 
    {

    AfxOleInit();
    GetDlgItem(IDC_RUN)->EnableWindow(FALSE);
    TransMOA();
    TransIsolate();
    SetTimer(1, m_nInterval, NULL);

    }
    然后ontimer函数如下
    void CDTDlgDlg::OnTimer(UINT nIDEvent) 
    {

    if(nIDEvent==1)
    {

    TransMOA();//可以用时间作为最大的选取
    TransIsolate();
    }
    CDialog::OnTimer(nIDEvent);
    }大侠帮忙阿!!!!!!!!!!!
      

  3.   

    看不明白吗?没有人愿意回答阿?或者我把代码发给你们,留下email
      

  4.   

    TransMOA();//可以用时间作为最大的选取
    TransIsolate();
    这二个的代码写出来啊
    你看联oracle的数据去掉
    把你的第一部写成ini 文件在程序中运行不知到那出的错了吗
    还有你用的是VC 6.0 还是vc 7.0 ado 是什么版本啊
    还有你的运行环境都是什么啊98 还是xp 还是windows2000,windwos2003
    也有可能是windows 2k 出的错或