Archive for January, 2012

January 29, 2012

Microsoft BizTalk Server 2010 online Virtual Labs

You can find Biz Talk Server 2010 online virtual labs here

MSDN virtual labs for Microsoft products:

http://msdn.microsoft.com/en-us/aa570323

Advertisements
January 29, 2012

Accessing a control inside a Loginview

you can access a control which is inside a login view using the following code:

 ASPxNavBar MyNavigationControl = (ASPxNavBar)viewPreSales.FindControl("nbMenuSPISPreSales");
January 22, 2012

The specified forest does not exist or cannot be contacted

I was trying to get the active directory group details of a user for me to authenticate an Application. The scenario is that when the server machine lives in another domain than the domain your machine is connected to.

The following code was works fine when i am in the same domain as the concerned domain which i am testing the application:

/// <summary>
        /// Gets a list of the users group memberships
        /// </summary>
        /// <param name="sUserName">The user you want to get the group memberships</param>
        /// <returns>Returns an arraylist of group memberships</returns>
        public static ArrayList GetUserGroups(string sUserName)
        {
            ArrayList myItems = new ArrayList();
            UserPrincipal oUserPrincipal = GetUser(sUserName);

            PrincipalSearchResult<Principal> oPrincipalSearchResult = oUserPrincipal.GetGroups();

            foreach (Principal oResult in oPrincipalSearchResult)
            {
                myItems.Add(oResult.Name);
            }
            return myItems;
        }

if not it means when the domain is different, you will get the error “The specified forest does not exist or cannot be contacted.”.

for you to sort out the above error assuming I am in a different domain at the same time the testing domain is different:

/// <summary>
        /// Gets a list of the users group memberships
        /// </summary>
        /// <param name="sUserName">The user you want to get the group memberships</param>
        /// <returns>Returns an arraylist of group memberships</returns>
        public static ArrayList GetUserGroups(string sUserName)
        {

            ArrayList myItems = new ArrayList();
            UserPrincipal oUserPrincipal = GetUser(sUserName);

            PrincipalSearchResult<Principal> groups = oUserPrincipal.GetAuthorizationGroups();
            var iterGroup = groups.GetEnumerator();
            using (iterGroup)
            {
                while (iterGroup.MoveNext())
                {
                    try
                    {
                        Principal p = iterGroup.Current;
                        myItems.Add(p.Name);
                    }
                    catch (NoMatchingPrincipalException pex)
                    {
                        continue;
                    }
                }
            }
            return myItems;
        }
January 16, 2012

Denaaali is out..

Microsoft has released SQL Server 2012 RC 0 (RC – Release Candidate).  The product will come in 3 main editions: Standard, Business Intelligence and Enterprise.

New TSQL Features in SQL Server 2012

For the moment i can mention following features in SQL Server 2012 (Denali),

Sequence

Most of time we used to create auto generated sequence numbers in our tables most of time for primary key fields. In other cases we had to store the generated sequence numbers in a table and then had to increase one by one and as well as we had to store the number generated at last. With this edition we can use our own sequence numbers as below:

CREATE SEQUENCE DemoSequence
START WITH 1
INCREMENT BY 3;

the NEXT VALUE FOR key word is used to get the next sequence number from a sequence.

Paged Data

Most of time we use the paging functionality within a DataGrid when there are lots of records in our database. In this scenario we use the paging functionality in DataGrids.  Now we can use the paging functinality from the database end as below in SQL Server 2012.

SELECT *
FROM Employees
ORDER BY EmployeeID
OFFSET 25 ROWS
FETCH NEXT 25 ROWS ONLY;

Exception Handling

We can throw exception within a SQL Code block.

 -- EXCEPTION HANDLING using THROW in SQL Server 2012 BEGIN TRY DECLARE @VALUE INT SET @VALUE = 1/0 END TRY BEGIN CATCH THROW END CATCH 

Once you execute the above command, you will get the error as below:

Msg 8134, Level 3, State 1, Line 5 Divide by zero error encountered. 

You can download sample databases for SQL Server 2012 RC 0 from here.

SQL Server 2012 RC0 – SSMS Review

SQL Server 2012 editions