Tuesday, April 26, 2011

How to Pass Empty String in Entity Framework

While working with Data Warehouse project, most database columns were designed as required even thought there are no data to populate with. In that situation, an empty string or blank will be used. 

Here is an example: The Note column is required and could be populated with empty string if there is no additional information provided.

image

When using Entity Framework to insert or update this type of field by passing in a blank, we often encounter a “field is required” validation error as below:

image

To overcome this issue, we could add Data Annotations as:

[MetadataType(typeof(Report_META))]
   public partial class Report
   {
   }
   public partial class Report_META
   {
       [Required(AllowEmptyStrings = true)]
       [DisplayFormat(ConvertEmptyStringToNull = false)]
       public object Note { get; set; }
 
    }

When setting AllowEmptyStrings to true for a specific data field, the framework does not perform validation and transforms the empty string to null. This value is then passed to the database.

When setting ConvertEmptyStringToNull  to false, the framework will not automatically convert the empty string value to null when the data field is updated in the database.

After adding the Data Annotations, we could use the blank/empty string to populate or modify the Note field now.





image

Saturday, March 19, 2011

Change SSRS Report Layout to keep the Column Headers Together

I created a SSRS report with 8 columns. When exporting the report in PDF format, the column headers were separated into two pages with default PORTRAIT layout.

 

image

image

To keep all the column headers together in one page, either I need to change the font size and squeeze them to fit into the 8.5 inches width or change the report layout to be Landscape.  Since it does not look good to squeeze them, I want to change the report to be Landscape layout.

To do it, here are the steps:

  1. Open the Report Properties
  2. Expend the PageSize
  3. Set the Width to 11in and Height to 8.5in and save it.
image

 

Now when exporting the report to PDF file, all the Column Headers are together in one page.

image

Friday, March 11, 2011

Cannot find the Performance Point Server “Decomposition Tree” option on the menu

Recently I am working on a PPS solution for the SharePoint 2010.  PPS 2010 introduces a new feature called Decomposition Tree that allows users to interactively drill down to the details. The Decomposition Tree option enables all of the following in one simple browser window:

  • Show how an individual value in a report can be broken down into its contributing members.
  • See all the members in a group in descending order
  • Choose which dimension you want to use for the next level of detail.

image

After I deploy my new dashboard to the SharePoint site,I cannot find the Decomposition Tree menu by right clicking on the Grid or the Chart.

image 

Doing several researches, I find that there is no Microsoft Silverlight installed on my client machine.

image image

Microsoft Silverlight enables this option. If it is not installed, or disabled, the menu command will be hidden.  In addition, if you are using an analytic chart or grid, you must design it using the Design tab, not the Query tab in order to use the Decomposition tree feature.

image

Tuesday, March 1, 2011

Create SSRS Report with SharePoint 2010 Integrated Mode

With SharePoint 2010, lots people would like to use SSRS Integrated mode. The advantage is that you can deploy data sources, reports, etc. to the SharePoint document library instead of the Report Manager web application. In addition, you could also use the new version of Report Builder that came with SQL Server 2008 R2 and deploy the reports to SharePoint.  Derek Sanderson posted a blog entry: How to Switch from SSRS Native Mode to SharePoint Integrated Mode with detailed graphic information to show step by step how to do it. Once you completed all the installation steps, you may want to create the SSRS reports on it. The following steps show you how to do it.

Create SSRS Report Document Library

In order to deploy or create SSRS artifacts, you need to add a document library with the appropriate content types.

  • Create a new document library called SSRS Report

image

  • Go to the Library tab and click on the Library Settings menu to configure the content type

image

  • In the General settings section, click on the Advanced settings link

image

  • Change the Allow management of content types? to “Yes” and click the OK button to apply the change

image 

  • In the Content Types section, click on the Add from existing site content types link

image

  • Select the Report Builder Model, Report Builder Report, and Report data source content types from the Available Site Content Types list to be added, then click the OK button to apply the change.

image

  • If you want to change the default or the visible order of the content types, you could click on the Change new button order and default content type link and modify accordingly.

image

image

  • Return back to the SSRS Report Document library, and click on the New Document from the Documents tab. Now you should be able to see the Report Builder menus that have been created.

image

  • To launch the Report Builder, click the Report Builder Report menu.  You can now use it to create the SSRS reports and save them to the SharePoint document library.

image

Deploy SSRS Report from Visual Studio to SharePoint
  • To deploy the SSRS report using Visual studio 2008, you will need to point to the SharePoint Server site, not the Report Manager site. Using the example we created, you will need to set the TargetServerURL to be the http://localhost/, and set the TargetReportFolder to be http://Localhost/SSRS Report

image

  • Make sure you don’t append the “/” at end of the TargetReportFolder such as http://Localhost/SSRS Report/, otherwise you will get the following deployment error:

    Error rsItemNotFound : The item 'http://Localhost/SSRS Report//Demo SSRS.rdl' cannot be found.
    Deploy complete -- 1 errors, 1 warnings

image

Manage SSRS Data Sources, Parameters, and Permissions
  • Go to the right side of the report and click the drop down to open the Context Menu. You could set the data source, configure the parameters, or manage the permissions for the report by clicking on the corresponding context menu.

image

View SSRS Report
  • You could now view the report from SharePoint Site by clicking on the report itself.

image

  • Or view the report from the Report Server Site by navigating to the report directory.

image

Sunday, February 20, 2011

Refresh PowerPivot data failed on the SQL Server Denali machine

I recently encountered an issue. When I try to refresh data for a PowerPivot Excel Spreadsheet on the SQL Server “Denali” machine, I got the ‘SQLNCLI10’ provider is not registered on the local machine error as below:

image

Issue:

The PowerPivot Excel Spreadsheet was created on a SQL 2008 R2 machine and was loaded with data from a remote SQL 2008 server by using the SQL Native Client 10 provider originally. When I open it on a SQL “Denali” machine that has no SQL Native Client 10 installed, it failed to refresh the data.  The Denali machine only has SQLNCLI11 provider installed.

Solution:

Convert the connection string to use Microsoft OLE DB provider

  • Open Excel and click on the PowerPivot window to open the PowerPivot Datasheet

image

  • Go to the Design tab and click on the Existing Connections button to open the Existing Connections window

image

  • Select the PowerPivot Data Connections that used by the datasheet and click on the Edit button.

image

  • On the Edit Connection window, click on the Advanced button

image

  • Change the Providers from SQL Server Native Client 10.0 to Microsoft OLE DB provider for SQL Server from the Drop down menu. 

image

  • Click the OK button and Save the connection change.

Now I could refresh the PowerPivot data on the machine that has SQL Server Denali installed. The Microsoft OLD DB provider for SQL Server should be the best choice to use in order to share the worksheet in different environments.

Note: I tried to install the SQL Server Native Client 10.0 provider and use it on the SQL Server Denali machine or tried to use SQL Server Native Client 11.0 provider showing as below, both methods did not work.

image

Wednesday, February 16, 2011

View the error detail for SharePoint unexpected error

During setting up a SharePoint 2010 development machine, I often experience a generic SharePoint error (A dialog box with “An unexpected error has occurred.” message) that telling me nothing but error. Most naive SharePoint developer/designer/user will have no clue what is wrong and how to correct it. Sometime there is not enough information could be provided to the administrator or ask for help.

UnexpectedError 

Derek Sanderson recently posted a blog entry about how to get the REAL error to show on web page which helped me a lot to view the error detail on the screen, so I could Google/fix it without dig into the logs files that I may not have permission with.

Since there are two web applications, one for the SharePoint default site, another is the SharePoint Central Admin, I modified the web.config file on both sites accordingly.  I will only leave those settings on for a development machine or sandbox/QA servers.

You may also want to check this out now:

http://dereksan.blogspot.com/2011/02/sharepoint-20072010an-unexpected-error.html

Tuesday, February 15, 2011

Cannot Display the List in Datasheet View

I recently set up and configured a SharePoint 2010 Enterprise Server on a VMware with Windows 2008 R2 Server as a development machine. The SharePoint Server has both Excel Services and PowerPivot Services installed and running without issues.  During testing the functionality of the SharePoint Server, I encountered the follow error while clicking on the Datasheet View button on the List Tools:
The list cannot be displayed in Datasheet view for one or more of the following reasons:
  • A datasheet component compatible with Microsoft SharePoint Foundation is not installed.
  • Your Web browser does not support ActiveX controls.
  • A component is not properly configured for 32-bit or 64-bit support.
image
This error indicated a component that required to display the Datasheet View is missing. Since I did not install any Microsoft Office Clients on the server such as Microsoft Word or Microsoft Excel, I will need to install the 32-bit version of Microsoft Office System Driver: 2007 Office System Driver: Data Connectivity Components to enable the Datasheet component.
After the component installed, the list could be displayed as a datasheet now.  This solution will work with the 64-bit version of Office 2010 as long as I am using a 32-bit version of an Internet browser.
 image 
Note:  If you are using a 64-bit version of an Internet browser, for example the 64-bit version of Microsoft Internet Explorer 8.0, there is no support for the Edit in Datasheet feature.
image
More information about this issue could be found: