how could i keep the value of a specific pointer?
-
In my dialog app i have 2 functions which use ADO connection to catch value from a database, and which put them into a "C" pointer of pointer and a regular pointer. I want after in a third function use the 2 pointers, which represent some of the input data. As i do it with 3 different button which each of them call one and only one function. For example the first, called OnLoadCorrel, put a whole matrix into a **pCorrel, the second one called On LoadVol, put a whole array into a *pVol. And, finally, the 3 function use the values needed coming from the matrix and the array. It's at this point of my app that there's a pb, because when i call the third function, the app doesn't recognize (or know) the value into both the pointers (perhaps the value have been lost?!?) So you could see the following lost, and i hope that soeone could find if what is wron in my app. ///////////////////////////////////////////////////////// So, in the CalcRiskPortDlg.cpp:: void CCalcRiskPortDlg::OnLoadVol() { UpdateData(TRUE); ::CoInitialize(NULL); LoadTables Table(m_dlgSector); int i; // _variant_t IndexCol; CString strValue; try { _ConnectionPtr pConnection=NULL; CString strTemp; strTemp.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\CalcRiskPort\\vol_correl1.mdb;"); _bstr_t strCnn(strTemp); TESTHR(pConnection.CreateInstance(__uuidof(Connection))); pConnection->Open(strCnn,"","",adConnectUnspecified); _RecordsetPtr pTp("ADODB.Recordset"); try { pTp->Open("Volatilité",strCnn,adOpenStatic,adLockOptimistic,adCmdTableDirect); if(!pTp->EndOfFile) { for(i=1;i<=m_dlgSector;i++) { pTp->MoveFirst(); pTp->Move(i-1); //strIndexCol=Table.ConvIntToVar((double)j); //strIndexCol=strIndexCol+strT; //_variant_t IndexCol(strIndexCol); *(Table.pVol+i)=pTp->Fields->GetItem("Volatilité")->Value; } } //dValue=pTp->Fields->GetItem("N° Titre")->Value; //Parameter2=pTp->Fields->GetItem(IndexColumn)->Value; pTp->Close(); } catch(_com_error &e) { AfxMessageBox("a pas bon"); } m_dlgValue=Table.pVol[3]; strValue.Format("%.9f",m_dlgValue); CEdit* PEdit=(CEdit*)GetDlgItem(IDC_VALUE); PEdit->SetWindowText(strValue); //Table.free_dmatrix(Table.pCorrel,1,m_dlgPortWeight,1,m_dlgPortWeight); pConnection->Close(); } catch(_com_error &e) { AfxMessageBox("a pas bon"); } ::CoUninitialize(); // TODO: Add your control notification handler code he