CAML is just like XML but it is Used as SQL Query for Sharepoint Lists ( list is like a grid view of asp.net but with much more rich functionality in which sharepoint stores its data ).With CAML one can perform SQL Quries to fetch out data from Sharepoint Lists.
Syntax:
<Query><Where><!--Comparison Operators here--><Eq><FieldRef Name=”insertFieldNameHere” /><Value Type=”insertDataTypeHere”>insertValueHere</Value></Eq></Where><OrderBy><FieldRef Name=”insertFieldNameHere” /><FieldRef Name=”insertFieldNameHere” /></OrderBy></Query>
Example :
Simple Sql Query
Select EmployeeName from Employes Where Salary < 3000
CAML :
<Query><OrderBy><FieldRef Name=”EmployeeName” /></OrderBy><Where><Lt><FieldRef Name=”Salary” /><Value Type=”INT”>3000</Value></Lt></Where></Query>
Here in above example we are not using any Table name because we will apply this query on List of Sharepoint like :
It is console programe for C#.net , but you must have WSS 3.0 installed.
class Program
{
static void Main(string[] args)
{
string siteUrl = args[0];
string listName = args[1];
string viewName = args[2];
SPSite site = new SPSite(siteUrl);
SPWeb web = site.OpenWeb();
SPList employeesList = web.Lists[listName];
SPQuery query = new SPQuery(employeesList.Views[viewName]);
System.Diagnostics.Debug.WriteLine(query.ViewXml);
Console.WriteLine(query.ViewXml);
Console.ReadLine();
}
}
thats a good post sir jee
ReplyDeleteplz tell me how a software house can take advantage from sharepoint?
i do have some points but i think you can give me a better precise answer.
thanx
Ali