Wednesday, May 2, 2012

Rich Text to Plain Text in SharePoint Client Side Object Model

It took me a while to figure out how to do this, so I thought it would be worthwhile to document it on the Internet as no matter how I searched I could not find a good solution. Basically I have a SharePoint field of type FieldMultiLineText (or SPFieldMultiLineText on the server object model). In the server object model there is the GetFieldValueAsText() method. But there was no such method in the CSOM. In the CSOM it is used like this:

string myString = item.FieldMultiLineText[Field_Name]

Simple enough!


Friday, January 28, 2011

T-SQL to Populate a Table of Country Codes with ISO 3166-1 Alpha-2 Codes and Names

You can use this query to populate a table with 2 character alpha country codes and their corresponding names.

Monday, January 3, 2011

CTP1 of SQL Server Denali (SQL Server 2011) will Blow up Your BIDS Dev Environment

If you already have SQL Server 2008 R2/SSIS installed you should not install the current CTP of Danali as BIDS 2008 will become unusable. Anytime you try to create a new project you will receive the following error:



'C:\Users\<username>\AppData\Local\Temp\temp.dtproj' cannot be opened because its project type (.dtproj) is not supported by this version of the application. 

To open it, please use a version that supports this type of project.
I suspect a reinstall of SSIS will correct the issue. For the moment I suggest a VM for the CTPs, should have taken my won advice!

Finding the Columns in a Database with Specific Names

You can use this T-SQL Query on SQL Server 2005 or greater to find all the columns that contain a word. In this example it would look for any column with the word number in it.

USE DataBase
GO

SELECT table_name
      ,column_name 'Column Name'
      ,data_type 'Data Type'
      ,character_maximum_length 'Maximum Length'

FROM information_schema.columns
WHERE column_name LIKE '%number%'
GO 

Thursday, December 30, 2010

Error Accessing SharePoint 2010 ListData.svc 'System.Data.Services.Providers.IDataServiceUpdateProvider' from assembly 'System.Data.Services, Version=3.5.0.0

If you receive this error

when attempting towork with SharePoint 2010 WCF Services you need to install one of the following hotfixes:

ADO.NET Data Services Update for .NET Framework 3.5 SP1 for Windows 7 and Windows Server 2008 R2

ADO.NET Data Services Update for .NET Framework 3.5 SP1 for Windows 2000, Windows Server 2003, Windows XP, Windows Vista and Windows Server 2008

Don't forget to download the x64 executable! And on a side note, I did have to restart my development system. Just a reset of IIS was not enough.

Thursday, December 16, 2010

Creating a Drag-and-Drop Upload Web Part for SharePoint Foundation 2010

Today I was working on a web part for SharePoint that would allow the user to either select files using an OpenFileDialog or via Silverlight 4’s drag-and-drop support. I came across a pretty serious issue once I completed my XAP file and uploaded it to my library. Drag-and-drop support was not available in SharePoint! When I would drag a file to the surface of the Silverlight web part and drop it, the browser would try to open the file. There is a pretty easy fix for this but I had to search all over the Interwebs to find the complete solution. Here is what you can do as well as an example of the code.

Setting an Environment Variable to the "14 Hive"

What SharePoint pro (developer or admin) does not hate the fact that the path to the root SharePoint directory is so dang long?

The solution? Create an environment variable mapped to the location.

"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN"

On Windows 7 right click "Computer" and select properties or in the search field type "System" and under Control Panel select "System". Click Advanced System Settings and Environment Variables. Click "New" under user variables. Then enter the alias you wish to give the path in Variable name (I normaly use just 14) and copy and paste the value in the code block above into the Variable value field. Start a new CMD session and test by typing
C:\> echo %14%
or open a run box and type %14%.