May 24, 2006 #1 Jo004060 Programmer Sep 25, 2003 18 CA Hello, im new to Accpac,VC++ 6 and to the comapi. I would like to know the correct C++ syntax of this VB line -- //Dim AccpacViewFields As AccpacCOMAPI.AccpacViewFields AccpacViewFields.Fields("whateverfieldname").value = "xyz" -- Thanks in advance Jo
Hello, im new to Accpac,VC++ 6 and to the comapi. I would like to know the correct C++ syntax of this VB line -- //Dim AccpacViewFields As AccpacCOMAPI.AccpacViewFields AccpacViewFields.Fields("whateverfieldname").value = "xyz" -- Thanks in advance Jo
May 31, 2006 Thread starter #2 Jo004060 Programmer Sep 25, 2003 18 CA I hope this will help C++ users using the comapi //----Fetch IAccpacViewPtr AccView; IAccpacViewFieldsPtr AccFields; int iSize=0; AccView = AccDBLink->OpenView2(_T("OE0480"), NULL); AccView->Init(); AccFields = AccView->Fields; AccView->Browse(_T(""), FALSE); if (AccView->Fetch()){ iSize = AccFields->GetFieldByName("INVNUMBERL")->GetValue().iVal; } AccView->Close(); //---- Using Read with a filter IAccpacViewPtr AccView; IAccpacViewFieldsPtr AccFields; CString strCoName; //CStringX="SAMLTD"; AccView = AccDBLink->OpenView2(_T("CS0001"), NULL); HRESULT hRes = AccView->Init(); AccFields = AccView->Fields; strFilter.Format("ORGID=\"%s\"", CStringX); AccView->Browse(strFilter.AllocSysString(), TRUE); AccView->Read(); strCoName = AccFields->GetFieldByName("CONAME")->GetValue().bstrVal; AccView->Close(); //-------Read with Put IAccpacViewPtr AccView; IAccpacViewFieldsPtr AccFields; CString strCoName; VARIANT vTemp; //CStringX="SAMLTD"; AccView = AccDBLink->OpenView2(_T("CS0001"), NULL); HRESULT hRes = AccView->Init(); AccFields = AccView->Fields; vTemp.vt = VT_BSTR; vTemp.bstrVal=CStringX.AllocSysString(); AccFields->GetFieldByName("ORGID")->PutWithoutVerification(&vTemp); AccView->Read(); strCoName = AccFields->GetFieldByName("CONAME")->GetValue().bstrVal; AccView->Close(); //------- Upvote 0 Downvote
I hope this will help C++ users using the comapi //----Fetch IAccpacViewPtr AccView; IAccpacViewFieldsPtr AccFields; int iSize=0; AccView = AccDBLink->OpenView2(_T("OE0480"), NULL); AccView->Init(); AccFields = AccView->Fields; AccView->Browse(_T(""), FALSE); if (AccView->Fetch()){ iSize = AccFields->GetFieldByName("INVNUMBERL")->GetValue().iVal; } AccView->Close(); //---- Using Read with a filter IAccpacViewPtr AccView; IAccpacViewFieldsPtr AccFields; CString strCoName; //CStringX="SAMLTD"; AccView = AccDBLink->OpenView2(_T("CS0001"), NULL); HRESULT hRes = AccView->Init(); AccFields = AccView->Fields; strFilter.Format("ORGID=\"%s\"", CStringX); AccView->Browse(strFilter.AllocSysString(), TRUE); AccView->Read(); strCoName = AccFields->GetFieldByName("CONAME")->GetValue().bstrVal; AccView->Close(); //-------Read with Put IAccpacViewPtr AccView; IAccpacViewFieldsPtr AccFields; CString strCoName; VARIANT vTemp; //CStringX="SAMLTD"; AccView = AccDBLink->OpenView2(_T("CS0001"), NULL); HRESULT hRes = AccView->Init(); AccFields = AccView->Fields; vTemp.vt = VT_BSTR; vTemp.bstrVal=CStringX.AllocSysString(); AccFields->GetFieldByName("ORGID")->PutWithoutVerification(&vTemp); AccView->Read(); strCoName = AccFields->GetFieldByName("CONAME")->GetValue().bstrVal; AccView->Close(); //-------
Jun 1, 2006 Thread starter #3 Jo004060 Programmer Sep 25, 2003 18 CA and use ::SysFreeString(bstr); BSTR bstrTmp; bstrTmp = CStringX.AllocSysString(); vTemp.vt = VT_BSTR; AccFields->GetFieldByName("ORGID")->PutWithoutVerification(&vTemp); ::SysFreeString(bstrTmp); Upvote 0 Downvote
and use ::SysFreeString(bstr); BSTR bstrTmp; bstrTmp = CStringX.AllocSysString(); vTemp.vt = VT_BSTR; AccFields->GetFieldByName("ORGID")->PutWithoutVerification(&vTemp); ::SysFreeString(bstrTmp);