multiple site libraries
Asked By sammy mc
08-Sep-10 09:29 PM
Hello all, I have to gather images from sites in a site collection by it's title name! any one know, the best practice!
re: multiple site libraries
Anand Malli replied to sammy mc
09-Sep-10 06:22 AM
Hi Sammy,
to get records from the multiple sites across the site collection you need to use SPSiteDataQuery as SPQuery will work only for the single site..
you can use following code snippet to get your records from all the sites of the site collection...
SPWeb web = SPContext.Current.Web;
SPSiteDataQuery q = new SPSiteDataQuery();
q.Lists = "<Lists BaseType='1'/>";
q.Query = "<Where><Gt><FieldRef Name='ID' /><Value Type='Number'>0</Value></Gt></Where>";
q.Webs = "<Webs Scope='SiteCollection' />";
q.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='ID' />"';
q.RowLimit = 10;
DataTable dt = web.GetSiteData(query);
you can modify the query as per the filter you want to apply...
I hope u got ur solution...
re: multiple site libraries
sammy mc replied to Anand Malli
09-Sep-10 09:40 AM
Thank you! It works with folders, sub-folders across the site collection. wondering I tried SPSiteDataQuery object oQuery
SPListItemCollection items = list.GetItems(oQuery); this does not work. any idea-
re: multiple site libraries
Anand Malli replied to sammy mc
10-Sep-10 12:08 AM
Hi sammy,
you have tried following...
SPSiteDataQuery oQuery = new SPSiteDataQuery();
SPListItemCollection items = list.GetItems(oQuery);
It will not work as you tried to access it along with the SPList. which is not possible. to use with SPList.GetItems(oQuery) you need to have an object of SPQuery not of SPSiteDataQuery
the reason behind this is SPQuery will target to a single list where as SPSIteDataQuery will target to multiple lists.
I hope u got the difference between those two....
let me know if any other doubts u're having....:D


How to customize Sharepoint search using CAML Query Hi How to customize Sharepoint search using CAML Query . in my project we want to by-id-not-by-value / hope this helsp you / . . . hi, SPQuery is the SharePoint object which is used to perform a query operation against SharePoint data.SPList.getItems(SPQuery) is the step, will return SPListItemCollection which satisfies the query SPQuery has one data member ‘Query’, which need to set before passing SPQuery object to SPList. try this using (SPWeb web = SPContext.Current.Site.RootWeb) { SPList mylist = web.Lists[ "Tasks" ]; SPQuery query = new SPQuery(); query.Query = "<Where> <Eq> <FieldRef Name = 'Status' / > " + "<Value Type = 'Text
Join two SharePoint list in CAML Query Hi I have to join two Sumit Kour Hi, To do a CAML query in a SharePoint list you can use the class SPQuery. Here's an example. Code: try { SPSite site = new SPSite SPWeb web = new site.OpenWeb(); SPList list = web.Lists["votre_liste"]; SPQuery query = new SPQuery(list.DefaultView); query.Query = " Une Valeur "; SPListItemCollection items = list.GetItems SPWeb web = new site.OpenWeb(); SPList list = web.Lists["votre_liste"]; SPQuery query = new SPQuery(list.DefaultView); query.Query = " Une Valeur "; SPListItemCollection items = list.GetItems libks- http: / / rmanimaran.wordpress.com / 2011 / 03 / 11 / new-in-sharepoint-2010-caml-query / http: / / praveenbattula.blogspot.com / 2010 / 02 / sharepoint-querying-caml-query-usage.html Hope this will help you you querying, building and customizing Web sites based on Windows SharePoint Services. The XML elements define various aspects of a WSS
SharePoint GridView Groupby count Hi All, I am using SharePoint Grid view in my custom aspx page where i have an option group the SharePoint Grid view by various factor such as title, id , user using System.Text; using System.Web.UI.WebControls; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using SPFormUtilities; namespace ListItemPermissionsReport { public class ReportListingByUser : LayoutsPageBase { protected Server.UrlEncode(text).Replace( "+" , "%20" ); } private void initPage() { / / Create a DataTable to hold the list item permission report data. DataTable dt = new DataTable(); dt.Columns.Add( "User" ); dt.Columns.Add( "ItemLink" ); dt.Columns grdListItemPermissions.Columns.Add(itemLinkField); grdListItemPermissions.Columns.Add(permissionsField); / / Populate the DataTable with the group name, user name, item link, / / and permissions a query that returns all the items in a list SPQuery query = new SPQuery(); bool isDocLib = false ; if (list is SPDocumentLibrary
code to read the items of particular folder / / Create a SPQuery Object SPQuery curQry = new SPQuery(); curQry.Folder = folder; / / Write the query curQry.Query = "<Where> <Eq GetItems(curQry); Hope this will help you HI / / Create a SPQuery Object SPQuery curQry = new SPQuery(); curQry. Folder = folder; / / Write the query curQry.Query = "<Where> <Eq only. Next you can iterate the datatabel returned. public static DataTable GetListItemJustFolders() { string query = "< mylistitemrequest > < Query > < Where > < Eq > < FieldRef Name = \ "FSObjType FieldRef Name = \ "ID \ " / > < FieldRef Name = \ "Title \ " / > < / ViewFields > < QueryOptions > < / QueryOptions > < / mylistitemrequest > "; DataTable dt = null; using(listservice.Lists listProxy = new listservice.Lists()) { listProxy folderUrl, dt); } } } return dt; } public static void GetListItemSubFolders(string parentFolder, DataTable retTable) { string query = "< mylistitemrequest > < Query > < Where > < Eq > < FieldRef Name = \ "FSObjType FieldRef Name = \ "Title \ " / > < / ViewFields > < QueryOptions > < Folder > " + parentFolder + "< / Folder > < / QueryOptions > < / mylistitemrequest > "; DataTable dt = null; using (listservice.Lists listProxy = new listservice.Lists()) { listProxy
access SPList items using C# code Hi, i am using sharepoint 2007. i want to retrieve the list items from sharepoint. i want to use sql query, is that possible. if we can't get list items directly. Because, the way SharePoint stores data in database, we can't get that directly using SQL query. For this we must use SharePoint object model, or SharePoint web services. Hi Jatin, can you pls explain me, how Can we use FullTextSQLQuery to fetch items form list in sharepoint? how to use this to get items? Hi, Please refer web = SPContext.Current.Web; SPList list = web.Lists["My Documents"]; SPQuery query = new SPQuery(); query.Query = "<OrderBy> <FieldRef Name = \ "Title \ " / > < / OrderBy> "; SPListItemCollection items = list i do, help me. using (SPSite siteCollection = new SPSite(siteUrl)) { DataTable dt = new DataTable(); DataSet Ds = new DataSet(); Microsoft.Office.Server.Search.Query.FullTextSqlQuery
User in home page. I have a list in http: / / sharepoint:231 / software / documents / default.aspx , and I am adding users task webpart in home page; http: / / sharepoint:231 / , but the user task webpart does not shows any user. When I am add the same webpart in http: / / sharepoint:software / , there the webpart is work fine. I need the SPWebPart> " ), XmlRoot (Namespace = "sa.WebParts.WebPartToDisplayGroupTasks" )] public class SPWebPart : Microsoft.SharePoint.WebPartPages. WebPart { private const EnumStatus _defaultStatus = EnumStatus .NotCompleted; private EnumStatus Webpart to display Group Tasks” ; } protected override void CreateChildControls() { Microsoft.SharePoint. SPList listSiteSetup = SPContext .Current.Web.Lists[ "Tasks" ]; Microsoft.SharePoint. SPQuery query = new Microsoft.SharePoint. SPQuery ();Microsoft.SharePoint. SPListItemCollection items = listSiteSetup.Items; DataTable dtTasks = items.GetDataTable(); DataColumn dtLink
Display Full List in Content Query Web Part in SharePoint 2010 Hi, I created a first list on Page and pages or custom field types you can best use the SPQuery object from the SharePoint object model. This object is located in the Microsoft.SharePoint namespace of the Microsoft.SharePoint.dll located in the Global Assembly Cache. Instantiate the object as follows: SPQuery qry = new SPQuery(); The most important property is the Query property, which needs It is possible that it is easier working with a DataTable . In that case you can execute the query as follows: DataTable listItemsTable = list.GetItems(qry).GetDataTable(); let me know whether its not Hi I am using only a single page in SharePoint 2010. . . . First I insert a list on Page. . .It display
pages or custom field types you can best use the SPQuery object from the SharePoint object model. This object is located in the Microsoft.SharePoint namespace of the Microsoft.SharePoint.dll located in the Global Assembly Cache. Instantiate the object as follows: SPQuery qry = new SPQuery(); The most important property is the Query property, which needs It is possible that it is easier working with a DataTable . In that case you can execute the query as follows: DataTable listItemsTable = list.GetItems(qry).GetDataTable(); let me know whether its SPSite oSite = new SPSite([Site URL]); / / change it to your sharepoint site URL SPWeb oWeb = oSite.OpenWeb(); SPList oList = oWeb.Lists idValues.toString()); } < / script > • Here is the output Regards 1. Using SharePoint designer, insert a data view web part onto the page