Thursday, June 13, 2013

SQL Server 2008: Saving Changes is not permitted

Scenario:
When you use Data Definition Language (DDL) to modify a table, and then you try to save the table in Microsoft SQL Server 2008, you may receive the following message:

Error:
Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.

Solution:
1. Go to: Tools > Options

2. Select the tab Designers and choose Tables and designers

3. Uncheck the option: "Prevent saving changes that require table re-creation".

4. Save, of course!

Thursday, June 6, 2013

No column header when exporting to CSV from Telerik Report

Check the config file. Make sure that the NoHeader attribute is set to "false"
<Telerik.Reporting>
<Extensions>
<Render>
<Extension name="CSV">
<Parameters>
<Parameter name="NoHeader" value="false"/>
<Parameter name="NoStaticText" value="true"/>
</Parameters>
</Extension>
</Render>
</Extensions>
</Telerik.Reporting>


What if you see the textboxes names and you don't want it of course?

namespace ClassLibrary3
{
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;
    using Telerik.Reporting;
    using Telerik.Reporting.Drawing;

    /// <summary>
    /// Summary description for Report1.
    /// </summary>
    public partial class Report1 : Telerik.Reporting.Report
    {
        public Report1()
        {
            /// <summary>
            /// Required for telerik Reporting designer support
            /// </summary>
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            this.textBox1.Name = "Text Box 1";
            this.textBox2.Name = "Text Box 2";
            this.textBox3.Name = "Text-Box-3";

        }
    }
}


Set the textboxes names according to your desired column header names.

Saturday, June 1, 2013

Telerik Report export to CSV has extra columns and headers of control names

Solution:
Configure the CSV rendering extension

Implementation:
By default the CSV rendering extension generates plain text files, without any formatting, and the first row contains the headers for all columns (you may choose whether to have this header row or not).

In Telerik Reporting, device information settings are used to pass rendering parameters to a rendering extension. You can specify device information settings in a variety of ways. You can use the <Telerik.Reporting> configuration section to specify rendering parameters globally. Programmatically, you can use the ReportProcessor.RenderReport() method. For more information about specifying rendering parameters globally, see Configuring Telerik Reporting.

The example below shows a sample application configuration file (App.config or Web.config depending on whether it is a Windows Forms or ASP.NET application) in which we modify the original CSV rendering extension settings to generate a CSV file without the header row (NoHeader = True) and all TextBox items that contain static text (not an expression) skipped (NoStaticText = True):
 
<?xml version="1.0"?> 
<configuration> 
  <!-- The configSectins element should be the first child element of configuration --> 
  <configSections> 
   <!-- Substitute Version=X.X.X.X with the assembly version you are using! --> 
   <section 
      name="Telerik.Reporting" 
      type="Telerik.Reporting.Processing.Config.ReportingConfigurationSection, Telerik.Reporting, Version=X.X.X.X, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" 
      allowLocation="true" 
      allowDefinition="Everywhere"/> 
  </configSections> 
       
  <Telerik.Reporting> 
    <Extensions> 
      <Render> 
        <Extension name="CSV"> 
          <Parameters> 
            <Parameter name="NoHeader" value="true"/> 
            <Parameter name="NoStaticText" value="true"/> 
          </Parameters> 
        </Extension> 
      </Render> 
    </Extensions> 
  </Telerik.Reporting> 
</configuration> 

If the report exported with default settings looked like this:

addressIDCaptionTextBox1,cityCaptionTextBox1,postalCodeCaptionTextBox1,textBox1,cityDataTextBox,postalCodeDataTextBox  
AddressID,City,PostalCode,20,Bothell,98011  
AddressID,City,PostalCode,21,Bothell,98011  
AddressID,City,PostalCode,22,Portland,97205  
AddressID,City,PostalCode,23,Seattle,98104  
AddressID,City,PostalCode,24,Duluth,55802  
AddressID,City,PostalCode,25,Dallas,75201  
AddressID,City,PostalCode,26,San Francisco,94109  
AddressID,City,PostalCode,27,Nevada,84407  
AddressID,City,PostalCode,28,Phoenix,85004  
AddressID,City,PostalCode,29,Memphis,38103  
AddressID,City,PostalCode,30,Orlando,32804  
AddressID,City,PostalCode,31,Ottawa,K4B 1T7  
AddressID,City,PostalCode,32,Montreal,H1Y 2H5 

With the given device information you will get:

20,Bothell,98011  
21,Bothell,98011  
22,Portland,97205  
23,Seattle,98104  
24,Duluth,55802  
25,Dallas,75201  
26,San Francisco,94109  
27,Nevada,84407  
28,Phoenix,85004  
29,Memphis,38103  
30,Orlando,32804  
31,Ottawa,K4B 1T7  
32,Montreal,H1Y 2H5  

Source: Configuring the CSV Rendering Extension

Monday, May 27, 2013

Solved: CLR20r3 mtm.exe System.TypeLoadException

System: Windows 7, MS Visual Studio 10 Ultimate

Summary: Error occurs in the Microsoft Test Manager when I try to open or create a new test case.

Error Returned:
Problem signature:
  Problem Event Name: CLR20r3
  Problem Signature 01: mtm.exe
  Problem Signature 02: 10.0.0.0
  Problem Signature 03: 4ba21172
  Problem Signature 04:
Microsoft.TeamFoundation.TestManagement.Activities.Common
  Problem Signature 05: 10.0.0.0
  Problem Signature 06: 4ba21169
  Problem Signature 07: 32
  Problem Signature 08: e
  Problem Signature 09: System.TypeLoadException
  OS Version: 6.1.7601.2.1.0.768.3
  Locale ID: 1033
  Additional Information 1: 0a9e
  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional Information 3: 0a9e
  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

Solution:

1. Reapply MS Visual Studio Service Pack 1.

2. Apply the hotfix rollup package that resolves the following issues in Microsoft Test Manager 2010 and that is dated October 2010 from Microsoft Support. Downloaded the KB2387011 fix from Microsoft Connect.

3. Check for related Windows Update and install.

Note:
My Silverlight has been affected by the fixes. The Visual Studio notified me that I needed the correct version of the Silverlight. The link for that was provided. Downloaded and installed the compatible Silverlight version.

Sunday, May 26, 2013

How to Key in Product Key in Visual Studio

Your trial period has already expired. You now want to register the product after purchasing a license.

Solution 1:
1. Go to Control Panel via Add or Remove Programs
2. Look for Microsoft Visual Studio <YourVersion>. Right click, then click Uninstall/Change.
3. It will load the installation components. Just wait until you go to the Maintenance Page.
4. At the lowest part of the window, you will see the textboxes to key in the Product Key.

Solution 2:
Here's a much simpler solution. Hehe...

MSDN says, to upgrade from a trial edition of Visual Studio Professional, Premium, or Ultimate, the following simple steps are just what you need to do:

1. Start Visual Studio in Run as Administrator mode.
2. On the menu bar, choose Help, Register Product.
3. Specify the product key, and then choose the Next button.

Wednesday, May 22, 2013

Validate Checkbox using Asp.Net Validator

In the designer / .aspx:


<asp:CheckBox ID="chkAgree" runat="server" />I agree to the <a href="#" class="link-blue"> Terms of Service</a> and <a href="#" class="link-blue">Privacy Policy</a>

<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ValidateCheckBox" CssClass="field_validation" ErrorMessage="Please accept our Terms of Service in order to avail our services."                 ></asp:CustomValidator>

and the Javascript code:

<script type="text/javascript">
    function ValidateCheckBox(sender, args) {
       if (document.getElementById("<%=chkAgree.ClientID %>").checked == true) 
          {
            args.IsValid = true;
          } 
          else 
          {
            args.IsValid = false;
          }
       }
</script>

Sunday, May 19, 2013

Basic template for Transactions in Sql Server


SET XACT_ABORT ON;

BEGIN TRY
    BEGIN TRANSACTION;

    -- Code goes here

    COMMIT TRANSACTION;
END TRY
BEGIN CATCH
    IF @@TRANCOUNT > 0
     ROLLBACK TRANSACTION;

    DECLARE
     @ERROR_SEVERITY INT,
     @ERROR_STATE INT,
     @ERROR_NUMBER INT,
     @ERROR_LINE  INT,
     @ERROR_MESSAGE NVARCHAR(4000);

    SELECT
     @ERROR_SEVERITY = ERROR_SEVERITY(),
     @ERROR_STATE = ERROR_STATE(),
     @ERROR_NUMBER = ERROR_NUMBER(),
     @ERROR_LINE  = ERROR_LINE(),
     @ERROR_MESSAGE = ERROR_MESSAGE();

    RAISERROR('Msg %d, Line %d, :%s',
     @ERROR_SEVERITY,
     @ERROR_STATE,
     @ERROR_NUMBER,
     @ERROR_LINE,
     @ERROR_MESSAGE);
END CATCH

Source