Using filtered view in Callout and Plugin

For using filtered view within the callout/plugin I used the following code

SqlConnection connection = new SqlConnection(“Data Source=dsname;Initial Catalog=dbname ;Integrated Security=SSPI;”);

string sqlQuery = @”select * from filteredOpportunity”;

SqlCommand cmd = new SqlCommand(sqlQuery, connection);


//// your logic here



But this code wasn’t returning any results .It was because callout/plugin run under the context of NT Authority\Network Service.

So we need to use impersonation in this case, for this we can use the following code


SqlConnection connection = new SqlConnection(Data Source=dsname;Initial Catalog=dbname ;Integrated Security=SSPI; Pooling=false”);

string sqlQuery = @” SETUSER ‘domainname\administrator’ select * from filteredOpportunity;

SqlCommand cmd = new SqlCommand(sqlQuery, connection);

//// your logic here



SETUSER – To impersonate the admin who has access to the filtered views. More about SETUSER


Pooling-False This is important otherwise we will get the below error


The connection has been dropped because the principal that opened it subsequently assumed a new security context, and then tried to reset the connection under its impersonated security context.

Check this wonderful post as well




Could not load XSL file. The system cannot find the file specified. (Exception from HRESULT: 0x80070002) Content By Query Web Part

We recieve this error while trying to edit ContentByQueryWebPart.

The reason for this error is because the publishing features are not enabled for the site.

So we need to enable the publishing features.

For this first activate Office Sharepoint Server Publishing Infrastructure feature found at

Site Collection Administration – Site Collection Features.

Than enable Office Sharepoint Server Publishing feature at Site Administration- Site features


Preventing your system from getting auto locked

Within most of the organization, there is a default setting that after a few minutes have escaped, the system gets locked itself, if system is left unattended. Well to prevent this i have written a small utility (windows application) which periodically sends user input to the system, making it to believe that some mouse movement has been made and thus stopping the system from getting locked.

Here we would be calling SendInput function within user32.dll

The SendInput function synthesizes keystrokes, mouse motions, and button clicks and that is what we need.

This is useful in case we are giving presentation or else reading some documents …

Following is the code for the same

1) Create a new windows application in C#

2) Add a button named btn_Unlock to it and a timer control named timer1.

3) Set enabled to false and interval to 120000 for timer control.

4) Put the following code to your form class

public partial class frmKU : Form






[DllImport(“User32.dll”, SetLastError = true)]

public static extern int SendInput(int
nInputs, ref INPUT
pInputs, int cbSize);

public struct INPUT


int type;



public struct MOUSEINPUT


int dx;

int dy;

int mouseData;

int dwFlags;

int time;

int dwExtraInfo;


// Call the


void btnUnlock_Click(object
sender, EventArgs e)


timer1.Enabled = true;

input = new INPUT();

resSendInput = SendInput(5, ref input, Marshal.SizeOf(input));


void timer1_Tick(object
sender, EventArgs e)


input = new INPUT();

resSendInput = SendInput(5, ref input, Marshal.SizeOf(input));




Bye …

Passed Exam MB2-634: CRM 4.0 Extending Microsoft Dynamics

Today I cleared the extension exam for Microsoft Dynamics CRM 4.0 with score of 82.

For version 3.0 the number of questions were 40 and passing score was 80.

This time around for version 4.0 there were 50 questions but how much is the passing score it wasn’t mentioned anywhere.

For preparation i used the the course material 8969 and CRM as a Rapid Development Platform book.

CRM as a Rapid Development Platform – I found this book really very useful..

Although from exam point of view the course material 8969 is more than enough !!!

Bye ..

Retrieving the COM class factory for component with CLSID {3D42CCB1-4665-4620-92A3-478F47389230} failed due to the following error: 8007042d.

I got this error while trying to perform a backup within backup and restore inside operations of Central Administration site.

I checked services on server within operations and it was showing that all the services had started, but on checking at services.msc i found out that the following service hadn’t started

Office SharePoint Server Search, after starting this service, the error got resolved.

Find more information over here


Customizing Export to spreadsheet in Survery or Adding columns for export to excel in Survey (Sharepoint)

We wanted to have created column value in the excel sheet for our survey responses. We modified the existing view to include the created column and then selected the option of Export to SpreadSheet. But it was not including the created column.


So the solution for this was to


Select All Responses View than

Site Actions – Edit Page – Modify the shared web part – Edit the current view – Than selecting the created column and copying the url of that page




Get the id of the view


Which is



%7B is equal to {

%7D is equal to }

%2D is equal to –


Go back to survey, click on Action – Export to spreadsheet – Save the query to your machine and make the following changes in the query






















Replace the above value with the value of your view i.e. 107DCB6B-83D8-439C-8996-F1B7782C8062.


Now when you will open this query it will show all the columns specified by you in the view.


Another option could be to use Data View web part for it and adding the required column to it through sharepoint designer. And than right clicking on it and selecting Export to Microsoft Excel from the context menu of the IE.