About Me

My photo
a Dynamic and Energetic guy.....

Sunday, December 20, 2009

BlackBox testing Vs. WhiteBox testing

White box testing refers to testing that works with the application's internals (or code). White box (or glass box) testing is typically done by developers using the IDE, debugger, and unit tests. This is going into the deep of logic & verifies the function.

Integration testing is considered functional, or black box, testing. Testers write test cases that indicate a given input into the application. Based on this input, they make assumptions about the output of the application. The testers then execute these integration tests as a black box. That is, they do not care about what happens inside the box (the code); they simply care that they get the expected results based on the given input.

Source:- 70-547 training kit book

Friday, December 18, 2009

Testing Our Code (As a Developer I Should)


Success baseline Start by defining a unit test that represents a common, successful path through your code. This test should represent the most likely scenario for executing your code.

Parameter mix Create a unit test that provides a varied mixture of parameters for a given method. This will ensure that more than just the success path works effectively. Consider creating this scenario as a data-driven unit test.

Bounds checking Create one or more unit tests that test the upper and lower limits of your code. That is, if your method takes a numeric value, you will want to test that method with values that represent both the upper and lower range of the data type.

Null values Make sure your unit tests measure what happens when null values are passed to a given method or property.

Error conditions Create unit tests that trigger error conditions in your code. You can tell the unit test that you expect a certain error as a result. If that error is not thrown, then the test will fail.

Code coverage scenarios Make sure that all the code in your method is called by one or more unit tests. You do not want untested code sitting inside of conditional statements. If this happens, write tests that hit those conditions inside your application code.



Best Practices

  • Write one test for each scenario you should test each outcome or scenario independently. If your method has a number of expected outcomes, write a test for each scenario.
  • Create atomic unit tests your unit tests should not require others tests (or a sequence of tests) to be run prior to their execution or as part of their execution.
  • Cover all conditions your unit tests should cover all cases. An effective set of unit tests covers every possible condition for a given method, including bounds checks, null values, exceptions, and conditional logic.
  • Run without configuration your unit tests should be easy to run (and rerun). They should not require setup or configuration. You do not want to define tests that require a specific environment every time you run your tests (or they will not be run). If setup is required, code that into a test-initialize script.
  • Test a common application state your unit tests should be run against a common, standard, good state. For example, if your application works with data, this data should be set to common state prior to the execution of each unit test. This ensures that one test is not causing an error in another test.

Source:- 70-547 training kit book

Sending Email Using Web.Config Entries in .NET

// Web.Config sample




<smtp from="website@website.com">

<network host="mail.website.com" password="" userName=""/>





// Code sample

using System.Net.Mail;

MailSettingsSectionGroup mailSettings = WebConfigurationManager.GetSection("system.net/

mailSettings") as MailSettingsSectionGroup;

protected void SendingEmail()


// Sending E-Mail

MailMessage message = new MailMessage(mailSettings.Smtp.From, WebConfigurationManager.AppSettings["RecipientList"], "Sending E-mail using web.config", "");

message.Priority = MailPriority.High;

SmtpClient smtp = new SmtpClient(mailSettings.Smtp.Network.Host);



Monday, December 7, 2009

Multi-tier Architecture in application development

We can categorize our n- tier architecture into 3 sections

  1. User Interface


    User interface code

    Business logic interaction code

  2. Middle Layer

    Business layer

    Application layer

    Database layer (This layer abstracts the retrieval and storage of data in your database)

  3. Database Layer

    Database layer

    Stored procedures

    Integration services

    Database tables, logs & indexes



MCPD (70-547) Designing and Developing Web-Based Applications Using the .NET Framework

Time Update using AJAX Controls







style="width: 100%; height: 100%; vertical-align: middle; text-align: center;">

<p>Current Time using AJAX control:</p>










function updateTime()

var label = document.getElementById('currentTime');

if (label) {

var time = (new Date()).localeFormat("T");
label.innerHTML = time;
window.setInterval(updateTime, 1000);



ASP.NET Concepts & theory

ASPX page execution order


Friday, December 4, 2009

Partial Methods in C#

This is a cool feature that comes with C#.
We can define a method & can omit the logic of that method, that is called Partial method.

If the implementation is not supplied, then the method and all calls to the method are removed at compile time.
This is useful as a way to customize generated code & the developer can work of same method without run-time problems. Because it is separated. We can validate data before it executes using these types of partial methods.

* Partial method should inside Partial Class
  • Partial method declarations must begin with the contextual keyword partial and the method must return void.

  • Partial methods can have ref but not out parameters.

  • Partial methods are implicitly private , and therefore they cannot be virtual.

// Code-generating tool defines a partial class, including
// two partial methods.
partial class ExampleClass
partial void onFindingMaxOutput();
partial void onFindingMinOutput();

// Developer implements one of the partial methods.
// Compiler
discards the signature of the other method.
partial class ExampleClass
partial void onFindingMaxOutput()
Console.WriteLine("Maximum has been found.");

Friday, November 20, 2009

Mockups Vs. Proof-of-Concept Prototypes

There are many types of prototypes. Some projects create UI prototypes. Others might proto-
type an architecture consideration. In fact, every project has different needs regarding a prototype.
However, for your purposes, these prototypes can be classified into two principal groups:
mockups and proof of concept.

A mockup is meant to verify the requirements and use cases through the creation of a number
of key screens in the system. Also called horizontal prototypes because they take
a single, horizontal picture of the application. They do not go deeply (or vertically) into the
other layers of the application such as the business objects and the database layers. Mockups
are a great way to determine whether the requirements are complete and understood. They
also help validate the use cases, the navigational structure, and some of the logical interactions
of the application.

Mockups do have shortcomings. They do not help you prove any of the architecture concepts
for the system. They also do not validate the technology decisions. Mockups are
great tool for moving from paper to something more tangible.

A proof-of-concept prototype(POC) is meant to validate the requirements and confirm the technology recommendations and high-level design. A POC is also called a vertical
prototype because it looks at the application across the entire stack (UI, services, business objects, and database). POC prototypes have also been called reference architectures,
because they provide a reference for the development team on just how the system
should work from top to bottom. This removes ambiguity, creates a standard, and eliminates
a lot of risk.
We create a POC prototype by choosing a key requirement of the application and
then building it out through each layer of the design. It makes more sense to prove out a riskier
requirement than to work with a well-known requirement. The latter might be easy, but it lacks
the risk reduction you are looking for with a proof of concept.

Sunday, November 15, 2009

Deploy 40 templates (.wsp solution) to sharepoint

first go to
C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\BIN

then type
stsadm –o addsolution –filename ApplicationTemplateCore.wsp

stsadm –o deploysolution –name ApplicationTemplateCore.wsp -allowgacdeployment -local

stsadm -o copyappbincontent

then go to central administration --> Operations --> Solution management

You can see your solution there(ApplicationTemplateCore).

Now you have to add your necessary templates...
Same as early
stsadm –o addsolution –filename ApplicationTemplateCore.wsp
stsadm –o deploysolution –name ApplicationTemplateCore.wsp -allowgacdeployment -local

Now go to central administration with a hope !
Create new site collection -->
Under application templates --> you will have your template(s)


Thursday, October 29, 2009

When we add controls dynamically, we are getting error like this.
Then we have to add this code to .ASPX file's code

public override void VerifyRenderingInServerForm(Control control)
Confirms that an HtmlForm control is rendered for the
specified ASP.NET server control at run time.
No code required here.

Then we are all works fine :) :) :)

read a .CSV file & create a dataset

protected void CreateImportDataSet()
if (FileUpload1.PostedFile.FileName == string.Empty)
{ lblMsg.Visible = true; return; }

//restrict user to upload other file extenstion
string[] FileExt = FileUpload1.FileName.Split('.');
string FileEx = FileExt[FileExt.Length - 1];
if (FileEx.ToLower() == "csv")

else { lblMsg.Visible = true; return; }

ArrayList counterOfUnNecessaryColumns = new ArrayList();

//create object for CSVReader and pass the stream
CSVReader reader = new CSVReader(FileUpload1.PostedFile.InputStream);
//get the header
string[] headers = reader.GetCSVLine(counterOfUnNecessaryColumns, 0);
DataTable dt = new DataTable();

ArrayList necessaryHeaders = new ArrayList();
necessaryHeaders.Add("First Name");
necessaryHeaders.Add("Middle Name");
necessaryHeaders.Add("Last Name");
necessaryHeaders.Add("Job Title");
necessaryHeaders.Add("E-mail Address");

necessaryHeaders.Add("Business Street");
necessaryHeaders.Add("Business City");
necessaryHeaders.Add("Business State");
necessaryHeaders.Add("Business Postal Code");
necessaryHeaders.Add("Mobile Phone");
necessaryHeaders.Add("Home Phone");

//add headers
for (int counter = 0; counter < headers.Length; counter++)
if (necessaryHeaders.Contains(headers[counter]))


string[] data;
int personIndex = 0;
while ((data = reader.GetCSVLine(counterOfUnNecessaryColumns, personIndex)) != null)
gv.DataSource = dt;

dt.TableName = "MyContacts";
Session["CsvDataSet"] = dt;

=====================================Base Class ====================================

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using System.Collections;

public class CSVReader
private Stream objStream;
private StreamReader objReader;

//add name space System.IO.Stream
public CSVReader(Stream filestream) : this(filestream, null) { }

public CSVReader(Stream filestream, Encoding enc)
this.objStream = filestream;
//check the Pass Stream whether it is readable or not
if (!filestream.CanRead)
objReader = (enc != null) ? new StreamReader(filestream, enc) : new StreamReader(filestream);

//parse the Line
public string[] GetCSVLine(ArrayList counterOfNecessaryColumns,int personIndex)
string data = objReader.ReadLine();
if (data == null) return null;
if (data.Length == 0) return new string[0];

ArrayList result = new ArrayList();
//parsing CSV Data
ParseCSVData(result, data, counterOfNecessaryColumns,personIndex);
return (string[])result.ToArray(typeof(string));

private void ParseCSVData(ArrayList result, string data, ArrayList counterOfNecessaryColumns,int personIndex)
int position = -1;
while (position < data.Length)
result.Add(ParseCSVField(ref data, ref position));

//Removing Unnecessary columns
for (int i = 0; i < counterOfNecessaryColumns.Count; i++)
result.RemoveAt(int.Parse(counterOfNecessaryColumns[i].ToString()) - i);
catch { }

private string ParseCSVField(ref string data, ref int StartSeperatorPos)
if (StartSeperatorPos == data.Length - 1)
return "";

int fromPos = StartSeperatorPos + 1;
if (data[fromPos] == '"')
int nextSingleQuote = GetSingleQuote(data, fromPos + 1);
int lines = 1;
while (nextSingleQuote == -1)
data = data + "\n" + objReader.ReadLine();
nextSingleQuote = GetSingleQuote(data, fromPos + 1);
if (lines > 20)
throw new Exception("lines overflow: " + data);
StartSeperatorPos = nextSingleQuote + 1;
string tempString = data.Substring(fromPos + 1, nextSingleQuote - fromPos - 1);
tempString = tempString.Replace("'", "''");
return tempString.Replace("\"\"", "\"");

int nextComma = data.IndexOf(',', fromPos);
if (nextComma == -1)
StartSeperatorPos = data.Length;
return data.Substring(fromPos);
StartSeperatorPos = nextComma;
return data.Substring(fromPos, nextComma - fromPos);

private int GetSingleQuote(string data, int SFrom)
int i = SFrom - 1;
while (++i < data.Length)
if (data[i] == '"')
if (i < data.Length - 1 && data[i + 1] == '"')
return i;
return -1;

Thursday, October 22, 2009

Wednesday, October 21, 2009

Diffrence between WebSite & WebApplication projects in .NET

A web site is just a group of all files in a folder and sub folders.

There is no project file.

All files under the specific folder - including your word documents, text files, images etc are part of the web site.

We have to deploy all files including source files (unless you pre compile them) to the server.

Files are compiled dynamically during run time.

There will be no single assembly created and you will nto see a "Bin" folder.

The benefits of this model is, you do not need a project file or virtual directory to open a project.

Disadvantage is, all files under the folder and considered to be part of the web site[since there is no project file].

The only way you can exclude a file from the website within the same directory is by renaming them with the extension .exclude

Friday, October 9, 2009

Sharepoint in Sinhala

Many developers had difficulties to implement Sharepoint in their own language.
In srilanka we had same issue.
So we worked hard & finally we got the results.

Monday, September 7, 2009

Sharepoint Webpart Concepts

In order to create WSS-style Web Parts, you must have a dependency on the Microsoft.SharePoint.dll and you must inherit from the WebPart base class in the Microsoft.SharePoint.WebPartPages namespace.

In order to create ASP.NET-style Web Parts, you have a dependency on System.Web.dll and inherit from a base class named WebPart in the System.Web.UI.WebControls.WebParts namespace.

When creating WSS 3.0 Web Part pages, you should use the WebPartZone control defined in the Microsoft.SharePoint.WebPartPages namespace. You do not want to use the WebPartZone control contained within ASP.NET 2.0.

Different controls contained in a WSS-style Web Part page

The preferred way to create Web Parts for WSS 3.0 sites is to create the ASP.NET style WebParts. As discussed before, this means inheriting from the WebPart base class in the System.Web.UI.WebControls.WebParts namespace and overriding the RenderContents method.

Sunday, September 6, 2009

Sharepoint Standard Versus Enterprise Edition

MOSS 2007 comes in both Standard and Enterprise Editions. Based on the needs we can choose to implement Standard Edition and upgrade to Enterprise Edition at a later time, or
immediately implement Enterprise Edition with all of its additional features.
Although there are many small differences between the two editions, the following are
the significant features included in Enterprise Edition but not in Standard Edition:

Excel Services
This feature provides access to Excel spreadsheets through a web browser and
offloads the calculations to the server. It makes only specific areas of the spreadsheet
visible to users, and ensures that there is “one version of the truth,” since
only specified users can modify the underlying data.

Report Center
This is a site provided out of the box that has been designed to simplify the management
of reports and data connections.

Business Data Catalog
This feature is a simplified way to bring data from external sources into Share-
Point without costly custom development. With it, users do not need to access
multiple systems to view the data they need—it is all available from one common
interface provided by MOSS.

Business Data Search
This feature allows users to search data that has been stored in separate systems
exposed through MOSS (such as those connected via the Business Data Catalog).

Forms Services
You can create forms within Microsoft Office InfoPath 2007 and publish them to
SharePoint using Forms Services, allowing users without the InfoPath client to
complete forms entirely through their web browsers.

Sunday, August 30, 2009

Usefull code samples in C#

// Getting the pressed key
if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
// Code for the "Enter" key

//Check Other Name that has Mr. & "Spaces"
public static bool IsOtherName(string strOtherName)
Regex Pattern = new Regex("[^a-zA-Z\\.\\ ?]");
return !Pattern.IsMatch(strOtherName);

// String format for "Money"
String.Format("{0:0,0.00}", objRenewal.policy.dblPremium.ToString())

Tuesday, August 18, 2009

Tuesday, July 28, 2009

Sharepoint 2010 Overview

It's time to have a look new features that we want in sharepoint !!!

  1. Look & Feel (Ribbon Control)
  2. Multi document Checkout + avoid from post backs
  3. Nice pop-up windows than response.redirects J
  4. Direct uploading & showing images from your computer to sharepoint
  5. SilverLight webpart
  6. Nice themes like "PowePoint Theme"
  7. Visio services running with sharepoint services (Visio is not necessary)
  8. Fully rich Sharepoint Designer
  9. Entities to connect SQL,LOB with Edit/Delete functions (OOB)
  10. Direct connect to the office tools like Office 2010 with a click J

Change the data in a Infopath form library programatically

First we have to take care few things
(1) We should allow unsafe upates = true
(2) We should check out the file

(3) We cant use our item update event inside "SPSecurity.RunWithElevatedPrivileges(delegate.."
Code is simple

SPSite objSite = new SPSite("http://sharepointsvr:123/");
SPWeb objWeb = objSite.RootWeb;
SPFolder oFolder = objWeb.GetFolder("Participant");
SPFileCollection collFiles = oFolder.Files;
objWeb.AllowUnsafeUpdates = true;

foreach (SPFile oFile in collFiles.Folder.Files)
SPListItem oListItem = oFile.Item;
oListItem["ProgramaticField"] = "Chanaka has done it";
oListItem.File.CheckIn("chana did");

Thursday, July 23, 2009

Sharepoint hints

Web Services that we are getting

How I enable Anonymous+Access

Get the response of web request programatically

StreamReader responseReader = null;
HttpWebRequest httpRequest = null;
httpRequest = (HttpWebRequest)WebRequest.Create("");
httpRequest.Method = "GET"; // User get data

HttpWebResponse webResponse = null;
webResponse = (HttpWebResponse)httpRequest.GetResponse();
Encoding enc = Encoding.Default;
responseReader = new StreamReader(webResponse.GetResponseStream(), enc);
String temp = responseReader.ReadToEnd();

Wednesday, July 22, 2009

Infopath data retrieve with Sharepoint

SPSite objSite = new SPSite("http://sharepointsvr:123/");
SPWeb objWeb = objSite.RootWeb;
SPList objList = objWeb.Lists["Participant"];
SPQuery objQuery = new SPQuery ();
SPListItemCollection objCollection = objList.GetItems(objQuery);
SPListItem objItem = objCollection[0];
SPFile objFile = objItem.File;
byte[] xmlFormData = objFile.OpenBinary();
XPathDocument ipForm = null;
using (MemoryStream ms = new MemoryStream(xmlFormData))
ipForm = new XPathDocument(ms);
XPathNavigator ipFormNav = ipForm.CreateNavigator();
XPathNavigator nodeNav = ipFormNav.SelectSingleNode("/my:myFields/my:fldFamilyName", GetFormNSM(ipForm));
string strValue = nodeNav.InnerXml;

//XML Namespace Creator

private XmlNamespaceManager GetFormNSM(XPathDocument ipForm)
const string strMYNamespacePrefix = "my";
const string strMYNamespaceURI = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-06-25T10:50:10";

const string strDIRNamespacePrefix = "d";
const string strDICNamespaceURI = "http://schemas.microsoft.com/sharepoint/soap/directory/";

XPathNavigator formAccess = ipForm.CreateNavigator();
XmlNamespaceManager namespaceMngr = new XmlNamespaceManager(formAccess.NameTable);
namespaceMngr.AddNamespace(strMYNamespacePrefix, strMYNamespaceURI);
namespaceMngr.AddNamespace(strDIRNamespacePrefix, strDICNamespaceURI);

return namespaceMngr;

Monday, July 13, 2009

RunWithElevatedPrivileges in sharepoint

When we try to get data from a document library that is not assigned for current user, we are getting this error.

Solution is:::::

//any code that we have to use

Sometimes even we add this delegate still it's not working.
That's because the object we are using made without elevated privileges.
(Ex:- We are creating SPWeb under the delegate, but the SPSite(parent object) object is outside the delegate, then we won't get chance to access data)

Monday, June 15, 2009

Sharepoint backup & restore using STSADM

C:\Documents and Settings\Administrator>cd C:\Program Files\Common Files\Microso
ft Shared\web server extensions\12\bin

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsadm -o backup -url http://sharepoint:5555/ -filename chana.bak

///Chana.bak is the name back up file

Operation completed successfully.

//// get the file from ‘12\bin\’ folder in development machine

//// transfer to the SERVER & put into ‘12\bin\’

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsadm -o restore -url http://sharepoint:5555/ -overwrite -filename chana.bak

Operation completed successfully.

Monday, May 25, 2009

My Career After One Year + My Interests In Next Year

We did many sharepoint implementations. But......

What we did more, other than sharepoint branding & small customization

(1) ( 1) Build using feature

(2) (2) Fire feature activation events & add tracking

(3) (3) Configure RMS (Rights Management Server)

(4) (4) Change whole master pages using features & SPD (Sharepoint Designer)

(5) (5) Add Ajax enable webparts into sharepoint sites

(6) (6) Active directory users migration using SSP

We did workflows other than simple approval workflows

(1) (1) Dynamic workflows (No of levels)

(2) (2) Dynamic approvers (different approvers)

(3) (3) Configure SSL

(4) (4) Reports generations using SSRS

(5) (5)Creating Collect feedback, Collect signature workflows

(6) (6) InfoPath forms integration using X-Path to workflows

Thursday, May 14, 2009

Write a TRIGGER when data INSERT into table

USE SalesOne;
IF OBJECT_ID ('SalesOne.reminder4', 'TR') IS NOT NULL
DROP TRIGGER SalesOne.reminder4;
ON SalesOne.dbo.Assets
--RAISERROR ('Notify Customer Relations', 16, 10);
UPDATE Assets SET LastUpdated = {fn now()}

Thursday, April 23, 2009

Play with SQL

// getting today
SET @today = CONVERT(CHAR(8), GETDATE(), 112)

//getting first day of month

//getting last day of month


WHERE (Date = '11/30/2009 12:00:00 AM')
UPDATE SOSupervisorRemarks SET IsUnblock='False' WHERE Date = '11/30/2009 12:00:00 AM'
INSERT INTO SOSupervisorRemarks (Date,IsUnblock) VALUES ('11/30/2009 12:00:00 AM', 'false')

//Getting Date Value from DateTime
dateadd(dd,0, datediff(dd,0,tblSLSale.ExchangeDate)) as ExchangeDate

Monday, April 20, 2009

Apply a style sheet + style class programatically

Finally we were managed to do this(Apply a style sheet programatically ) :)

Table objTable = new Table();

objTable.Attributes.Add("href", "txtstyle.css");
objTable.Attributes.Add("type", "text/css");
objTable.Attributes.Add("rel", "stylesheet");
objTable.Attributes.Add("class", "ph11");


Remember to add tag in "ASPX" page also

Friday, April 17, 2009

Tips in Windows Mobile Development

*** It is a scale down version, So you wont get all features as .NET framework
*** You should install .NET Compact framework(3.5) + SQL compact version.

*** Try to use ShowDialog() other than Show()
*** Use Singleton pattern to avoid load many occurances of single form
*** Its easy to user picture/image buttons than menu click
*** Its good to use cursor until data is loading to the form

*** SQL Compact framework doesn't support statements like "IF EXITS"

*** If you want to connect to a Mobile(Compact) DB in ASP.NET add following method
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
this allow you to connect to a DB that has .SDF extension :)

Thursday, March 12, 2009

Active Directory Properties

Now its simple, You can get more details using the "DirectoryEntry" object

It consists of a hashtable, that includes properties


























Sunday, March 8, 2009

How to find selected checkbox controls inside Webpage

using System.Collections.Generic;

protected void StoreSelectedDates()
Control[] allControls = FlattenHierachy(Page);

foreach (Control control in allControls)
CheckBox mycheckBox = control as CheckBox;
if (mycheckBox != null)
if (mycheckBox.Checked)
string setDay = mycheckBox.ID.Substring(3);
catch (Exception ex)

private Control[] FlattenHierachy(Control root)

List list = new List();
if (root.HasControls())
foreach (Control control in root.Controls)
return list.ToArray();

How to write a Stored Procedure with a Cursor

-- =============================================
-- Author: chanaka
-- Create date: 04/03/2009
-- Description:
-- =============================================
CREATE PROCEDURE dbo.SearchRegionWise
-- Add the parameters for the stored procedure here
@firstPara nvarchar(25),
@secondPara nvarchar(25)
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.

-- Insert statements for procedure here
DROP TABLE TemporySearchData
CREATE TABLE TemporySearchData(OfferID nvarchar(50), UserID nvarchar(50), StartLocation nvarchar(100), Destination nvarchar(100))
DECLARE @firstName nvarchar(25)
DECLARE @nextName nvarchar(25)
DECLARE @addString nvarchar(25)
DECLARE @UserID nvarchar(50)
DECLARE @StartLocation nvarchar(50)
DECLARE @Destination nvarchar(50)

DECLARE firstCursor CURSOR FOR (SELECT LocationName FROM dbo.tblLocation WHERE (RegionId =
(SELECT RegionId FROM dbo.tblLocation AS tblLocation_1 WHERE (LocationName = @firstPara))))
OPEN firstCursor
FETCH NEXT FROM firstCursor INTO @firstName
PRINT @firstName

DECLARE loopCursor CURSOR READ_ONLY FOR (SELECT LocationName FROM dbo.tblLocation WHERE (RegionId =
(SELECT RegionId FROM dbo.tblLocation AS tblLocation_1 WHERE (LocationName = @secondPara))))
OPEN loopCursor
FETCH NEXT FROM loopCursor INTO @nextName
PRINT @nextName

DECLARE loopInfo CURSOR READ_ONLY FOR (SELECT DISTINCT dbo.tblTravelOffer.tblTravelId, dbo.tblTravelOffer.UserId, dbo.tblTravelOffer.StartLocation, dbo.tblTravelOffer.Destination FROM dbo.tblTravelOffer WHERE dbo.tblTravelOffer.StartLocation = @firstName AND dbo.tblTravelOffer.Destination = @nextName)
OPEN loopInfo
FETCH NEXT FROM loopInfo INTO @addString, @UserID, @StartLocation, @Destination
INSERT INTO TemporySearchData (OfferID, UserID, StartLocation, Destination)
VALUES (@addString, @UserID, @StartLocation, @Destination)
FETCH NEXT FROM loopInfo INTO @addString, @UserID, @StartLocation, @Destination
CLOSE loopInfo
FETCH NEXT FROM loopCursor INTO @nextName
CLOSE loopCursor
FETCH NEXT FROM firstCursor INTO @firstName
CLOSE firstCursor
DEALLOCATE firstCursor
select * from dbo.TemporySearchData

Friday, March 6, 2009

Get User belongs Active Groups

public string[] getUserBelongsGroup(string userName)
DirectoryEntry objDirEntry = GetUserInforamtionFromAD(userName);

PropertyValueCollection objPVC = objDirEntry.Properties["memberof"];
string[] strData = new string[objPVC.Count];
for (int count = 0; count < objPVC.Count; count++)
strData[count] = objPVC[count].ToString().Split(new char[] { ',' })[0].Substring(3);
return strData;

public DirectoryEntry GetUserInforamtionFromAD(string _UserName)
// Create a DirectorySearcher object using the user name as the LDAP search filter. If using a directory other than Exchange, use sAMAccountName instead of mailNickname.
string strActualName = _UserName.Split(new char[] {'\\'})[1].ToString();
DirectorySearcher searcher = new DirectorySearcher("(cn=" + strActualName + ")");

// Search for the specified user.
SearchResult result = searcher.FindOne();

if (result == null)
return null;
// Create a DirectoryEntry object to retrieve the collection of attributes (properties) for the user.
DirectoryEntry user = result.GetDirectoryEntry();
return user;

Thursday, February 19, 2009

Create Record Repository inside Sharepoint

1.Create a web application

2.Use “Record Center” template to create site

[eg: http://server03:2222]

3. Central administration --> Application Management --> External Services --> Records Center --> ”Ironone Record Center” -->


4. Create a document library --> Add a document

5. Right Click the document --> Send to "Ironone Record Center"

Tuesday, January 27, 2009

Simple AJAX Application

(1) Install ASP.NET AJAX VS2008

(2) Go to C:\Program Files\Microsoft ASP.NET, you can see ASP.NET 2.0 AJAX Templates for Visual Studio 2008 folder --> that implies your installation is succeeded J

(3) Open Ajax enabled ASP.NET web application through VS 2008

(4) Add two labels & one button(say Button1)

(5) Add following code sample into Page_Load() method

Label1.Text = DateTime.Now.ToString();

Label2.Text = DateTime.Now.ToString() ;

(6) Run the application & check the text changes in labels(both change)

(7) Now time to add AJAX extensions

a. Toolbox --> AJAX Extensions --> UpdatePanel

(8) Add “UpdatePanel” control into webpage

(9) Drag Label2 into the “UpdatePanel” area

(10) Run the application & check the changes in labels(both change)

(11) Now go to the “Source” tab of webpage

(12) After the > ContentTemplate tag add the following code sample

<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />


(13) Run the application & check the changes in labels(Now only Label1 change)

(14) Your AJAX panel is working J

Tuesday, January 6, 2009

CCF Tips

Problem --> Are you suffering to get "CCF Activities" items in your toolbox?
Solution --> Find C:\Program Files\Microsoft CCF 2008\Source Code\Framework\ InstallCcfActivityToolbox.exe

Note --> Still suffering?
Solution --> Close the Visual Studio, Click
InstallCcfActivityToolbox.exe again, Open Visual Studio again


My Masters