Skip to main content

Posts

Showing posts from September, 2011

ASP.NET 4.5 , Visual Studio 2011 Developer Preview is here! Also an update on Denali!

Hi, The next version of ASP.NET is here for a developer preview. You can read more about it and watch videos at the following link http://www.asp.net/vnext To know more on whats new in this release you can refer the following link http://www.asp.net/vnext/whats-new Be sure to also visit the following link to understand whats new in Visual Studio 2011 http://msdn.microsoft.com/en-us/library/bb386063(VS.110).aspx Coming to SQL Server 2011 (code named Denali) there is an update on one of its projects named juneau- You can read about this here - http://msdn.microsoft.com/en-us/magazine/hh394146.aspx Developer's first reactions to the Visual Studio 2011 Preview can be read here- http://www.infoworld.com/d/application-development/visual-studio-2011-developers-first-reactions-176797 Happy Reading

Error while configuring search (new scope) in SharePoint 2010 (on Windows Server 2008 R2 SP1)

When trying to configure search in SharePoint 2010 on Windows Server 2008 R2 SP1, you can get the following error when trying to create a new scope through central administration The search application <app id> on server <server name> did not finish loading. View the event logs on the affected server for more information. This error can be resolved by running the following command in Visual Studio Prompt psconfig -cmd upgrade -inplace b2b -wait -force It would take a few mins for the command to complete following which you should be able to create your new scope without any issues. Note this issue seems to occur after installing Service Pack 1

Saving a document in SharePoint 2010 document library

When we create a new document (lets say Word Document) in Sharepoint 2010 document library, while saving the document the following dialog appears. This means that the document is going to be saved on your local hard drive and not on the SharePoint site. To resolve this one needs to do the following steps - Open Microsoft Word, click on File -> Options  Click on Trust Center in the dialog that opens Next Click on Trust Center Settings In Trust Center Settings  click Protected View tab and uncheck Enable Protected view for files located in potentially unsafe locations as shown below. Click on OK to close the open dialogs and close Microsoft Word. Now if you try to create a new word document in SharePoint and try to save it, you should get the following dialog Which means that now your files will be successfully stored in the Sharepoin

Query to get list Stored Procedures ordered by modified date

Getting list of stored procedures ordered by modified date can be useful to find recently modified sps -- Queries the sys.objects system view to gather information -- about user defined stored procedure database objects; -- specified with type='P'. -- order by modified date-- SELECT FROM sys . objects -- User defined objects system view WHERE type = 'P' -- Only return stored procedures ORDER BY modify_date desc name , create_date , modify_date Refer the following link on msdn for more information that you can get using sys.objects http://msdn.microsoft.com/en-us/library/ms190324.aspx

My favourite Open Source (C#, ASP.NET) Projects

1. Time Tracker - If you ever want to create a time tracker or utilization tracker (for tracking time spent on each project and resource utilization) with C# and ASP.NET, the good news is that you don't need to start from scratch. You can download/watch demo of  Time Tracker Starter Kit  from the following link- http://www.asp.net/downloads/starter-kits/time-tracker Any issues while installing or customizing the same are often addressed in the following forum link http://forums.asp.net/1005.aspx 2. Bug Tracker - If you need to log bugs/defects in any project at one central location Bug Tracker is a wonderful project which you can use. It is easily customizeable and its written in C# and ASP.NET. Only con of this project is that the code model used is single page and not code-behind. It can be used for customer support or as a help desk. http://ifdefined.com/bugtrackernet.html

Asp.Net - Export GridView to Excel

Exporting gridview contents to excel is one of the most common requirements in many asp.net applications. I found a helper class in the following link to be very useful- http://mattberseth.com/blog/2007/04/export_gridview_to_excel_1.html One limitation of the class is that it doesn't work if you have grid paging turned on - it only exports the rows that are visible on the page, not the whole grid. To workaround this call the disable Gridview paging as the first line of the Export() Sub and re-enable paging as the last line of the Export() Sub. Also to have this working with a Master Page you need to override a method called VerifyRenderingInServerForm as follows public override void VerifyRenderingInServerForm(Control control) { } If you want to remove any columns from being exported then add a int16[] parameter to the export function and call a new method (displayed below) instead of PrepareControlForExport in the export function.; code: private stat

VBA function- Get column letter from column number, Worksheet Exists

One often needs a Excel Column's alphabetic letter from the column number e.g Column No.3 corresponds to ColumnLetter - C      Column No.27 corresponds to ColumnLetter - AA I use the following function to achieve this Public Function ColumnLetter(ColumnNumber As Integer) As String   If ColumnNumber > 26 Then     ' 1st character:  Subtract 1 to map the characters to 0-25,     '                 but you don't have to remap back to 1-26     '                 after the 'Int' operation since columns     '                 1-26 have no prefix letter     ' 2nd character:  Subtract 1 to map the characters to 0-25,     '                 but then must remap back to 1-26 after     '                 the 'Mod' operation by adding 1 back in     '                 (included in the '65')     ColumnLetter = Chr(Int((ColumnNumber - 1) / 26) + 64) & _                    Chr(((ColumnNumber - 1) Mod 26) + 65)   Else    

VBA Procedure to apply borders to a excel range of cells

The following VBA procedure can be used to apply borders to a range of cells Public Sub ApplyBorder(ToRange As Range, intColorIndex As Integer)      On Error Resume Next      With ToRange         With .Borders(xlDiagonalDown)             .LineStyle = xlNone         End With         With .Borders(xlDiagonalUp)             .LineStyle = xlNone         End With                 With .Borders(xlEdgeLeft)             .LineStyle = xlContinuous             .Weight = xlThin             .ColorIndex = intColorIndex         End With         With .Borders(xlEdgeTop)             .LineStyle = xlContinuous             .Weight = xlThin             .ColorIndex = intColorIndex         End With         With .Borders(xlEdgeBottom)             .LineStyle = xlContinuous             .Weight = xlThin             .ColorIndex = intColorIndex         End With         With .Borders(xlEdgeRight)             .LineStyle = xlContinuous             .Weight = xlThin             .ColorIndex

VBA Function to return unique values

'The following function returns a unique list if passed an array of values Public Function UniqueValues(SourceValues As Variant) As Variant 'Returns a variant containing the unique values contained within SourceValues 'If called from a worksheet array formula, returns either a row or column array, as needed. Dim Items As New Collection Dim i As Long, j As Long, m As Long, nCols As Long, nRows As Long, Row As Long Dim rg As Range Dim cel As Variant, Result() As Variant On Error Resume Next Set rg = Application.Caller For Each cel In SourceValues    If cel <> "" Then Items.Add CStr(cel), CStr(cel) Next If rg Is Nothing Then Else     nCols = rg.Columns.Count     nRows = rg.Rows.Count     m = Application.Max(nCols, nRows) End If On Error GoTo 0 i = Items.Count ReDim Result(1 To i) For Row = 1 To i      j = 0     If rg Is Nothing Then         For Each cel In SourceValues             If cel = Items(Row) Then j = j + 1         Next         Result(Row) = Items(

Kinect SDK

If you are excited about starting to develop applications which use the Kinect Sensor I can recommend two great resources where you can start learning- 1. The first one is a blog which gives a quick overview of installing the sdk and what it contains. Also it gives a few tips on getting started with building Kinect applications. Also it gives links to some projects build in the sdk and uploaded on codeplex. http://michaelcrump.net/archive/2011/06/17/the-busy-developers-guide-to-the-kinect-sdk-beta.aspx 2. But probably the most important resource is the following link http://channel9.msdn.com/Series/KinectSDKQuickstarts It explains the following things: 1. Installing and Using the Kinect Sensor 2. Setting Up Your Development Environment 3. Skeletal Tracking Fundamentals 4. Camera Fundamentals 5. Working with Depth Data 6. Audio Fundamentals

VBA in Excel to automate IE for crawling a web page

If you want to open a website and go through the results of a webpage using VBA you can achieve it by first including a reference to Microsoft HTML Object Library in your VBA editor. The following snippet of code should be a good starting point of how you can achieve the same Sub GoToWebSiteAndPlayAround() Dim appIE As Object ' InternetExplorer.Application Dim sURL As String Application.ScreenUpdating = False Set appIE = CreateObject("InternetExplorer.Application") 'URL with the search term 'Cancer' at Science sURL = "http://www.google.com?q=vba" 'this URL to be replaced by your target web page With appIE .navigate sURL ' uncomment the line below if you want to watch the code execute, or for debugging '.Visible = True End With ' loop until the page finishes loading Do While appIE.readyState <> 4 DoEvents Loop 'Get info from HTML by ID and Name Dim outerDiv, innerSpan, requiredtext, HTMLDoc Dim

Automatic Table of Contents in Microsoft Word

There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (here you have to highlight which text        in your document will appear in the table of contents please read the rest of the article        to know how to do this.)   2.  Insert the automatic table of contents in your document. To achieve this please use following steps For MS Word 2003 Prepare your document for a table of contents :    1.  On the View menu, point to Toolbars, and click Outlining.    2.  Select the first heading that you want to appear in the table of contents.    3.  On the Outlining toolbar, select the outline level that you want to associate with the selected paragraph.    4.  Repeat steps 2 and 3 for each heading that you want to include in the table of contents. Insert the automatic table of contents :    5.  Click where yo

Handy Tips on working on Microsoft Word or Outlook

I have complied a small set of handy tips for working on Microsoft Word or Microsoft Outlook – 1. To change case (toggle between upper case, lower case and camel case),  select the text and press Shift+F3 2. While editing documents, it is not uncommon to delete words, phrases, and the like. Different people take different approaches to the task. For instance, some people just select the text and press Delete, while others may simply hold down the Delete or Backspace keys until the unwanted characters disappear. If you are in the latter group, and you spend a lot of time pressing Delete or Backspace, you may be interested in a handy shortcut provided by Word. All you need to do is hold down the Ctrl key to speed up your editing tasks. Here is a list of what you can achieve with this Ctrl+ <-- (left arrow key)        Goto Previous word Ctrl+ --> (right arrow key)      Goto Next word Ctrl+Delete      Delete Next word Ctrl+Backspace      Delete Previous word An interesting use o

Working with Dates in Excel

While using dates in excel one may have come across a situation that after entering a date in a cell, it shifts to the left-hand side of the cell. What this means is that Excel has not recognized the input as a valid date; i.e., the date is considered invalid by the application. The expected format of the date depends on the machine’s regional settings. For example, if the regional options of your machine is set to English (United Kingdom), then you need to enter dates in dd/mm/yyyy format (or dd-mm-yyyy). When you enter dates in the expected format they are aligned to the right hand side by default. (Note – here, “by default” means formatting of the cell has not been altered to impose left or center alignment). In this case (U.K. settings), if you type a date in mm/dd/yyyy format (or mm-dd-yyyy), then the date will move to the left-hand side of the cell (Please note that for this to happen the day in the date should be greater than 12). OR some of the dates will be left-aligned a

Mouse Double-Clicks When You Try to Single-Click

I was once struggling with a problem with my optical mouse. On clicking once the mouse clicked twice. After doing some search on the net I found the following link. http://www.indiabroadband.net/computer-hardware-software- tips-tricks/14122-most-common-problem-optical-mouse- solved.html I tried the utility created by the author and guess what the solution worked. Basically, the program intercepts "up" events for the left mouse button, and ignores any subsequent "up" events that follow within a very small time. Just in case you are facing a similar problem try the solution in the above link and hopefully your mouse will work as expected.

PowerShell snap in not loading in SharePoint Management Shell

Recently on one of my VMs I came acrosss the above error on opening SharePoint Mangement Shell, which mentioned that "The term 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1' is not recognized as the name of a cmdlet, function, ..." As a newbie to PowerShell it took me quite some time of searching for a solution I realized I simply had to enable a feature in the server manager (as the OS is Windows Server 2008 R2 Enterprise). The steps for this are listed in the link below- http://techinfoblog.net/how-to-enable-install-the-windows-powershell-integrated-scripting-environment-ise-in-windows-server-2008-r2/ Note: The name of the feature will vary based on OS version - e.g. for Windows Server 2008 the feature name is Windows PowerShell. if you see the following error message File "testpath.ps1" cannot be loaded because the execution of scripts is disabled on this