Tuesday, September 11, 2012

SSIS: Convert Gregorian Dates to Hijri Dates

Conversion of Gregorian Date to Hijri Date using SSIS Script Component:

Gregorian Dates can be converted to Hijri dates using SQL Script components.

Create the Output column needed in the script component.
After that add following Code to the Script Editor.

 Public string ConvertDateCalendar(DateTime DateConv, string Calendar, string DateLangCulture)
    {
        DateTimeFormatInfo DTFormat;
        DateLangCulture = DateLangCulture.ToLower();
        /// We can't have the hijri date writen in English. We will get a runtime error - LAITH - 11/13/2005 1:01:45 PM -

        if (Calendar == "Hijri" && DateLangCulture.StartsWith("en-"))
        {
            DateLangCulture = "ar-sa";
        }

        /// Set the date time format to the given culture - LAITH - 11/13/2005 1:04:22 PM -
        DTFormat = new System.Globalization.CultureInfo(DateLangCulture, false).DateTimeFormat;

        /// Set the calendar property of the date time format to the given calendar - LAITH - 11/13/2005 1:04:52 PM -
        switch (Calendar)
        {
            case "Hijri":
                DTFormat.Calendar = new System.Globalization.HijriCalendar();
                break;

            case "Gregorian":
                DTFormat.Calendar = new System.Globalization.GregorianCalendar();
                break;

            default:
                return "";
        }

        /// We format the date structure to whatever we want - LAITH - 11/13/2005 1:05:39 PM -
        DTFormat.ShortDatePattern = "dd/MM/yyyy";
        return (DateConv.Date.ToString("f", DTFormat));
    }

Modify the following function to call date converter function.

Here you go. By using above method you have converted Gregorian dates to hijri dates in SSIS.


Monday, September 10, 2012

Create DB Script and Restore DB using SqlCmd Utility and .sql file

How to Restore DB from Script:
If you have got db script with data in .sql file then no need to worry. You can run your SQL script with out opening it using SqlCmd utility as follows.


sqlcmd -S servername\instancename -i C:\abc.sql


How to create DB Script:
RightClick DB -->Generate Scripts



Here you go. This way you can create DB script with data included.

Wednesday, June 27, 2012

Some or all identity references could not be translated" when trying to create a new web application through SharePoint Administration

"Some or all identity references could not be translated" when trying to create a new web application through SharePoint Administration

 

Solution:

Use the below command using SharePoint command line Utility
stsadm.exe -o updatefarmcredentials -userlogin -password

This will resolve your issue

 

Tuesday, June 26, 2012

SharePoint 2010 error: HTTP Error 503. The service is unavailable

SharePoint 2010 error: HTTP Error 503. The service is unavailable.

 This might me due to the following reasons.
SharePoint administration site is in stopped state in application pool in IIS.
Or 
If SharePoint administration site was running under a user account and after installation password was changed for that user then that might be the case for this error.

Solution: In IIS go to application pool then go to the advanced settings of SharePoint central administration and change the pass of the account to current.