Archive

Archive for the ‘Misc’ Category

SharePoint Online – Setting up PowerShell

SharePoint global administrator can use the SharePoint Online Management Shell to manage the site and content.

Following are the steps we should do for that

  1. Install Windows Management Framework 3.0 – You can download it from http://go.microsoft.com/fwlink/p/?LinkID=244693. This require a system restart
  2. Install SharePoint Online Management Shell – You can download it from http://go.microsoft.com/fwlink/p/?LinkId=255251

Once this is done, you can start “SharePoint Online Management Shell” and use following command to connect

Connect-SPOService -Url https://tenant-admin.sharepoint.com -credential admin@tenant.com

After connection, you can execute SPO cmdlets and work remotely.

Example:

Get-SPOSite

will retrieve all sites.

Take a look at this http://technet.microsoft.com/en-us/library/cb90889b-9c1e-4cec-ab0f-774be623022f(v=office.15) to find the list of supported cmdlets

Advertisements
Categories: Misc, SharePoint Online Tags:

PHP – MySQL Insert

January 16, 2014 1 comment

After long wait I got my hands dirty with PHP and MySQL.

$dbServer = 'localhost';
$dbUserName = 'username';
$dbPassword = 'password';
$connection = mysql_connect($dbServer, $dbUserName, $dbPassword);
if(!$connection) {
		  die('Connection Failed : ' . mysql_error());
}

$insertStatement = 'INSERT INTO TableName(Column) VALUES("Value")';
mysql_select_db('databaseName');
$returnValue = mysql_query( $insertStatement, $connection );
if(!$returnValue){
		  die('Insertion Failed : ' . mysql_error());
}
echo "Data Inserted.";
mysql_close($conn);

Categories: Misc Tags: ,

OleDBConnection – Unspecified error

August 5, 2013 1 comment

On top of SharePoint 2010, I was trying to create an excel parser where I hit with this strange “Unspecified error”. The exception is getting generated from “OleDBConnection.Open” method

There was no inner exceptions or stack traces, which made it difficult to find the root cause. After trying out different steps like uninstalling office, restarting iis etc. eventually I resolved it by the below 3 steps

  1. Download latest Access Databas Engine http://www.microsoft.com/en-in/download/details.aspx?id=13255. Ensure to select the correct platform 32 vs 64
  2. Connection string = “Provider=Microsoft.ACE.OLEDB.12.0;Data Source=fileLocation;Extended Properties=”Excel 12.0 Xml;HDR=Yes;IMEX=1”
  3. In the web configuration file turn off Impersonation <identity impersonate=”false” />

In the connection string I am using HDR=Yes, this mean the first row in the excel file is a header row. IMEX=1 will force the excel cells to be treated as Text rather than the Excel General type which converts the data (The feature I hate most)

Congratulations 2013 Microsoft MVP!‏

April 2, 2013 2 comments

Really excited when I saw this mail on my Inbox yesterday

ImageProxy.mvc

Dear Amal Hashim,

Congratulations! We are pleased to present you with the 2013 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in Visual C# technical communities during the past year.

The Microsoft MVP Award provides us the unique opportunity to celebrate and honor your significant contributions and say “Thank you for your technical leadership.”

Mike Hickman
Director
Community Engagement
Microsoft

Categories: Misc Tags: , ,

JavaScript – Escaping quotes

While passing data through AJAX post we might want to escape quote characters. One option is to escape using JavaScript method, but this will encode the entire string. The simplest approach is using the replace method.

     data.replace(/(['"])/g, "\\$1")
Categories: jQuery, Misc Tags: ,

Windows 8 – Downloading File

Here is a snippet for downloading file using C#

    async Task<bool> DownloadFile(Uri source, StorageFile destination)
    {
        try
        {
            BackgroundDownloader downloader = new BackgroundDownloader();
            DownloadOperation download 
             = downloader.CreateDownload(source, destination);
            await download.StartAsync();

            return true;
        }
        catch
        {
            return false;
        }
    }

If you want to show progress indicator, then add a ProgressBar object into the UI. And use StartAsync().AsTask(Progress)

SSIS – Daily Refresh Job

In this post I am going to explain the steps we should follow to create an SSIS package that run’s every night. The package will ensure already imported records are updated and new records are created in the destination system.

For demonstration I am assuming a source system, say CRM exists and it has a view as shown below

s0

The job we are going to create will import this data into destination system, say Employee table as shown below

s01

Now open SQL Business Intelligence Studio. Create new project and select “Integration Services Project” as shown below

s1

From toolbox, drop a “Data Flow Task”

s2

Double click to go inside the Data Flow Task and add a new OLE DB source control

s3

Double click OLE DB Source control.

s4

First we need to setup a new connection. For that click on the New button, enter the source database information. Once completed, select the connection. And set other properties as shown below

s5

Next step is to add a Lookup transformation. This will help us to identify whether the record exists in the destination or not.

s8

Before that we should add a new connection to the destination.

s6

Now we can setup the lookup transformation as shown below

s7

Lookup transformation by default fail if no match is found. In our case for new records this scenario will come up. To ensure new records pass through the pipeline we should set the Error Output properly.

s91

Next, add a conditional split control

s9

Drop the data flow arrow into conditional split control, which brings up following dialog. Select “Lookup Match Output”

s90

Double click Conditional Split control and set following values

s92

Now we should add the ole db destination and a ole db command controls. To “OLE DB Destination” we should select the input “New_Records” from Conditional Split. To “OLE DB Command” we should select the input “Modified_Records” from conditional split.

Make following changes to OLE DB Destination

s93

s94

Make following changes to OLE DB Command control

s95

s96

s97

s98

Now the package is ready for testing, hit F5 to run the package

s99

In my next post I will show how to schedule this package to run every night.

Thanks!

Categories: Misc, SQL 2005, SQL 2008 Tags: ,