Category Archives: Visual Studio 2010

C# Read Excel file with worksheets

using System.Data; using System.Data.OleDb; private void readExcel () { OleDbConnection conn = new System.Data.OleDb.OleDbConnection((“provider=Microsoft.ACE.OLEDB.12.0; ” + (“data source=C:\\Projects\\Driver Reports.xlsx; ” + “Extended Properties=’Excel 12.0;HDR=Yes;IMEX=1;’;”))); // Select the data from Sheet1 of the workbook. OleDbDataAdapter ada = new OleDbDataAdapter(“select * from … Continue reading

Posted in Excel, Visual Studio 2010, SharePoint 2016 | Leave a comment

Add an assembly into .wsp package

I have a project that needs to use Microsoft Exchange WebServices (Microsoft.Exchange.WebServices.dll). After I deployed the solution into SharePoint 2016, sometimes I receive the following error: System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.Exchange.WebServices, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of … Continue reading

Posted in SharePoint 2010, SharePoint 2016, Visual Studio 2010, Web Service | Leave a comment

System.Net.WebRequest throws a “(401) Unauthorized” error: The Double Hop Syndrome.

When using System.Net.WebRequest to POST (or GET) data to a SharePoint page, a 401 Unauthorized error occurs. For example: Uri address = new Uri(“http://mysiteurl.com/somepage.aspx?someparam=something”); System.Net.WebRequest request = System.Net.WebRequest.Create(address); request.Credentials = System.Net.CredentialCache.DefaultCredentials; request.Method = “GET”; System.Net.WebResponse response = request.GetResponse();  response.Close(); The … Continue reading

Posted in Visual Studio 2010, SharePoint 2016 | Leave a comment

Get all items from a list performance

Running on a list with 4,000 items. Option 1 is on average 1 second slower than Option 2. Option 1: using (SPSite currentSite = new SPSite(SPContext.Current.Site.ID)) { using (SPWeb currentWeb = currentSite.OpenWeb(“crm”)) { DateTime dt1 = DateTime.Now; DateTime dt2 = … Continue reading

Posted in SharePoint 2010, Visual Studio 2010, SharePoint 2016 | Leave a comment

Create a notification banner on top of every page in a SharePoint 2010 site collection using delegate control

We wanted to create a notification banner on top of every page in a SharePoint 2010 site collection like this: You could modify the master page for each site but that very cumbersome. So we will use the “Delegate Control” … Continue reading

Posted in SharePoint 2010, Visual Studio 2010 | Leave a comment

Default Server Ribbon Customization Locations

Reference: https://msdn.microsoft.com/en-us/library/office/ee537543%28v=office.14%29.aspx SharePoint 2010 Last modified: April 05, 2011 Applies to: SharePoint Foundation 2010 The Server ribbon in Microsoft SharePoint Foundation supports customization of the default tabs, groups, and controls. In order to customize these objects, you need the specific … Continue reading

Posted in SharePoint 2010, Visual Studio 2010 | Leave a comment

SharePoint: RegistrationId List Template Type IDs

Reference: http://techtrainingnotes.blogspot.com.au/2008/01/sharepoint-registrationid-list-template.html Below is a list of RegistrationIDs for use with API code and CustomAction Features (for user created list types) and any other list types I have found. In this article you will find: A table of all of … Continue reading

Posted in SharePoint 2010, Visual Studio 2010 | Leave a comment