请高手帮助:关于开发Web Part时使用SPQuery的问题

我的开发环境:
windows 2003 Server (en), SPS2003 (en), VisualStudio2003(en)

我在开发一个web part时,想要对"Status Report" list中的item进行选择,该list的定义中有个column,定义为:name: Report Type, type: Choice,我的代码片断如下:

     SPWeb web = new SPSite(siteURL).OpenWeb();     
     web.Lists.IncludeRootFolder = true;
     SPList list = web.Lists["Status Report"];
     SPDocumentLibrary doclib = (SPDocumentLibrary)list;

     SPQuery query = new SPQuery();
     query.Query = "<Where><Eq><FieldRef Name='Reprot Type'/><Value Type='Choice'>Monthly</Value></Eq></Where>";

     SPListItemCollection listItems = doclib.GetItems(query);
     
     if (listItems.Count > 0)
         ret = true;

结果程序运行到GetItems(query)之后,throw an excpetion: "No such field name No field was found with that name. Check the name, and try again."

如果我将query语句改为对另外一个"Title" column(该column的名字只有一个单词)进行条件选择,结果就正确。
如果我将query语句改为对另外一个"Title" column(该column的名字有两个单词,中间有空格)进行条件选择,结果和"Report Type"一样,出现exception。

哪位高手能够告诉我,该怎么写才正确?

posted on 2005-05-25 12:59  Elton  阅读(1720)  评论(4)    收藏  举报

导航