void CKsView::OnButton4() 
{  
  CString s;
if (m_grid1.GetFocusRect()==1)
{
AfxMessageBox("请选择要修改的题目");
return;
}
m_combo1.GetWindowText(s);
if(s=="")
{

AfxMessageBox("请选择要添加的试卷名");
return;
}
     if(m_bTableOpened)
 {
CloseTable(); 
 }
_RecordsetPtr  m_Recordset2;
CREATEINSTANCE(m_Recordset2, Recordset);
CString strSelect;
int istxh,itmbm,iscore;
  istxh=1;
  itmbm=1;
  iscore=10;
strSelect=CString("INSERT INTO wzsjb ")
+ "(stxh,"
+ "tmbm,"
+ "score,"
+ "sjh)"
+ "VALUES(%d,%d,%d,'%s')";
strSelect.Format(CString(strSelect),istxh,itmbm,iscore,s); try{
m_Recordset2->putref_ActiveConnection(m_piConnection);
    m_Recordset2->Open(_bstr_t(strSelect),vtMissing,adOpenDynamic,adLockOptimistic,adCmdText);
 
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bs=_bstr_t("Error:")+_bstr_t(e.Error())+_bstr_t("Msg:")
     +_bstr_t(e.ErrorMessage())+_bstr_t("Description:")
+_bstr_t(e.Description());
m_bDataOpened=false;
MessageBox(bs,bstrSource);
return;
}
}根据我刚才分析是这段子程序用问题 应该是m_combo1.GetWindowText(s);
但是我把s="aa";照样有问题,只有原来程序和界面不加如组合框这控件时无问题.

解决方案 »

  1.   

    如果我不运行上面原程序的OnButton4() 事件当我关闭程序时不会弹出
            Microsoft Visual C++ Debug Library 错误提示
    如果我屏蔽上面的void CKsView::OnButton4() 
                     {
                         /*
                     ..........
                      */
                     }
    再运行程序时施行  OnButton4{}  这段空事件. 当结束程序时也弹出另一个错误
         
      Microsoft Visual C++ Debug Library
           Debug Error!
        Program:...FT VISUAL\VC98\新建文件夹\DY1800\DEBUG\DY1800.EXE
        DAMAGE:after Client block(#621) at 0x007FBD40.
    (Press Retry to debug the application)
             终止(&A)  重试(&R)  忽阅(&I)
     
     本人刚学VC不久,还不知道在程序中也没运用什么内存分配在定义变量时也是常见的几种.
    希望大家帮帮小弟.
        
           谢谢!!!!!!!!!!!!!