Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VC++ basic question

Status
Not open for further replies.

Jo004060

Programmer
Sep 25, 2003
18
0
0
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
 
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();
//-------
 
and use ::SysFreeString(bstr);

BSTR bstrTmp;
bstrTmp = CStringX.AllocSysString();
vTemp.vt = VT_BSTR;
AccFields->GetFieldByName("ORGID")->PutWithoutVerification(&vTemp);
::SysFreeString(bstrTmp);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top