袁绍伦
路人甲
路人甲
  • 注册日期2003-08-08
  • 发帖数654
  • QQ164646905
  • 铜币1336枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1543回复:0

C++ Example of a NotesQuery Dataset

楼主#
更多 发布于:2003-09-03 21:38

void CMapXView::OnNotesQuery() {
 CMapXDataset ds;
 CMapXNotesQueryInfo NQI;
 COleVariant nqiVt, fldsVt;
 COptionalVariant optVt;
 CMapXFields flds;

 try {
  NQI.CreateDispatch(NQI.GetClsid());

  // Change this to point to the appropriate server and
  // database; a sample database is included on the MapX CD.
  // Leave the server field empty if accessing a local
  // database.
  NQI.SetServer("");
  NQI.SetDatabase("C:\\Windows\\Desktop\\LotusNotes\\Notesamp.nsf");

  NQI.SetQuery("@ALL"); // Or some other appropriate Notes query
  // for example "@ismember(State;""NY"":""TX"":""CA"":""FL"")"

  nqiVt.vt = VT_DISPATCH;
  nqiVt.pdispVal = NQI.m_lpDispatch;
  nqiVt.pdispVal->AddRef();

  // Create a new Fields object, and describe the fields we
  // are going to import. Using a Fields object is required
  // for NotesQuery datasets.
  flds.CreateDispatch(flds.GetClsid());
  flds.Add(COleVariant("State"), COleVariant("State"),

   COleVariant((long)miAggregationIndividual),
   COleVariant((long)miTypeString));
  flds.Add(COleVariant("value"), COleVariant("value"),
   COleVariant((long)miAggregationSum),
   COleVariant((long)miTypeNumeric));

  fldsVt.vt = VT_DISPATCH;
  fldsVt.pdispVal = flds.m_lpDispatch;
  fldsVt.pdispVal->AddRef();

  // Create the dataset and add a simple theme
  ds = m_ctrlMapX.GetDatasets().Add(miDataSetNotesQuery, nqiVt, COleVariant("NotesDS"),
   COleVariant("State"), optVt, optVt, fldsVt, optVt);

  ds.GetThemes().Add(miThemeRanged, "value", "NotesThematic");
 } catch (COleDispatchException *e) {
  e->ReportError();
  e->Delete();
 } catch (COleException *e) {
  e->ReportError();
  e->Delete();
 }
}
喜欢0 评分0
愿意和大家交朋友! QQ:47559983 MSN:shaolun_yuan@hotmail.com eMail:shaolun-yuan@163.com
游客

返回顶部