Tuesday, May 11, 2010

selecting records between two dates

ALTER procedure [dbo].[uspLeaveDetails](@User varchar(15),@FromDate datetime,@ToDate datetime)
AS
BEGIN

Select FromDate,ToDate,
NoOfDays,FirstName from UserDetails,LeaveDetails
where FromDate > =@FromDate AND ToDate <=@ToDate AND
UserDetails.USerID=@User
End

Tuesday, March 30, 2010

Sharepoint Website Collection.



Listing all the websites from the share point site and its owner.

SPSite site = new SPSite("http://localhost");
SPWeb web=site.AllWebs;
foreach(SPWeb web in collection)
{
DropDownList1.Items.Add(web.Author.ToString());
}


Listing all lists in the website
SPSite site = new SPSite("http://localhost/SiteDirectory/IT"); //IT-site name
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Posts"]; // a List in the site
foreach(SPListItem col in list.Items)
{
DropDownList2.Items.Add(col.Title.ToString()); // Item in the List
}

SPWebCollection

SPWebCollection lets you to enumerate the Websites in the Share point server.


SPSite site = new SPSite("http://win-zmmypcbnz7k/");


SPWebCollection collection = site.AllWebs;
foreach (SPWeb web in collection)
{
Response.Write(web.Author.ToString());
}

Monday, March 15, 2010

Webservice String array value in C #

When we works with Webservice,we can't use the .NET data types like DataSet or DataTable,ArrayList as return value.
So we need to convert these into unified data type such as string or string array.


public string[] RecordAll()
{
SqlConnection con = new SqlConnection("Server=Your server\\SQLExpress;Database=SPTest; Trusted_Connection=Yes");
con.Open();
DataSet ds = new DataSet();
ArrayList al = new ArrayList();
SqlCommand cmd = new SqlCommand("Select * from Registers",con);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds, "Registers");
foreach (DataRow row in ds.Tables[0].Rows)
{
al.Add(row[0]);
al.Add(row[1]);
}
string[] stringArray = (string[])al.ToArray(typeof(string));
return stringArray;

}