Thursday, July 23, 2009

Salesforce APEX "Invalid bind expression type of Datetime for column of type Date"

When trying to compare a Date field with a DateTime field in an APEX SOQL query I got the following error:

Invalid bind expression type of Datetime for column of type Date

The solution was to use date.newinstance(year, month, day) rather than the raw DateTime value in the comparison. Year, month, and day are found using the methods of the same name on the DateTime object.

Tuesday, July 21, 2009

Nelson .NET User Group Presentation - Best practice - Caching - 19th of August

Upcoming presentation

Kirk Jackson will be giving a presentation on Wednesday the 19th of August.

Title:
Best practice - Caching

Abstract:
At some point in your application development, you'll need to start caching data or the output of your program. Scalability, performance, bytes transferred, speed, reliability and robustness can all be improved through judicious use of caching. The first half of the talk will cover the types of caching and motivations for using them -- through all layers of your app: SQL, C#, ASP.NET and through to the browser cache. The second half of the talk will briefly cover memcached, which is used by all the cool kids (YouTube, Facebook, Trade Me), and then introduce the Microsoft project code named Velocity (currently CTP), which brings all that coolness and more to the .NET platform.

Useful links:

When:
Wednesday 19th August 2009
Gather at 11:50 am, starting at 12:00 pm.
Approximately 1 hour plus pizza afterward.

Where:
FuseIT Ltd,
Ground Floor,
7 Forests Rd,
Stoke,
Nelson
(Off Nayland Rd and behind Carters)

http://local.live.com/default.aspx?v=2&cp=-41.299774~173.236231&style=r&lvl=16&alt=-1000
or
http://maps.google.com/?ie=UTF8&om=1&z=17&ll=-41.299774,173.236231&spn=0.005239,0.010042&t=h

If you are parking on site, please use the parks marked FuseIT that are at the back of the site.

Giveaways:
A Windows Game

Catering: Pizza & Drinks
Door Charge: Free

RSVP to me if you are going to attend so I can guesstimate the food and drink requirements.

However, feel free to turn up on the day though if you can't commit at the moment.

Please feel free to invite anyone who may be interested in attending.

Monday, July 6, 2009

Sitecore CMS 6 - Error 27506 during installation

Error 27506.Error executing SQL script attach. Line 5. Directory lookup for the file "D:\websites\instance name\Databases\\Sitecore.Core.MDF" failed with the operating system error 3(error not found). (5133)

The Sitecore installation wizard kept failing at the Executing SQL Install Script step when installing to a remote database. Running the install from the database server avoided the issue.

I've also seen the error appear as:

Error -2147217900: failed to execute SQL string, error detail: Directory lookup for the file "D:\websites\instance name\Databases\MDF\...\Sitecore.Core.ldf') FOR ATTACH"

Friday, June 26, 2009

Sitecore CMS 6 - "Could not access value needed to update license snapshot. Value name: 'baseDictionaryEntries'. "

This is the second time I've run into this exception when trying to update the Sitecore installation using the provided package.

Tuesday, June 23, 2009

Postback issues with Sitecore 6 - typesThatShouldNotBeExpanded

I've run into this a couple of times now. An ASP.NET control, say the FormView, posts back to the server to change the page contents, say transitioning from the view to edit mode. The page loads, but some of the state or the postback event get lost along the way.

If the same control/code works just fine outside of Sitecore start looking for a solution with the rendering/typesThatShouldNotBeExpanded element in the web.config.

According to ListView and DataPager under Sitecore context"

As Sitecore runs [the] "layout pipeline" during [the] page rendering process, some of the complex ASP.NET controls may fail due to changes in the control tree. Adding type to the mentioned list allows affected ASP.NET controls to work the way they were initially designed.
<!-- RENDERING -->
  <rendering>
      <typesThatShouldNotBeExpanded>
        <type>System.Web.UI.WebControls.DropDownList</type>
        <type>System.Web.UI.WebControls.GridView</type>
        <type>System.Web.UI.WebControls.Repeater</type>
        <type>System.Web.UI.WebControls.DataList</type>
        <type>System.Web.UI.WebControls.FormView</type>
        <!-- Fix issue with the LoginStatus logout link not working when nested in a LoginView -- >
        <type>System.Web.UI.WebControls.LoginView</type>
      </typesThatShouldNotBeExpanded>
  </rendering>

See also:

Thursday, June 18, 2009

Extending System.Web.UI.WebControls.Style to handle all style attributes. E.g. text-align

When using the Page.Header.StyleSheet.CreateStyleRule method I ran into a limitation of the System.Web.UI.WebControls.Style class. I could only set a small subset of the available CSS attributes. In particular, I couldn't set text-align using the WebControls.Style class.

By overriding the Style.FillStyleAttributes method I can add additional CSS attributes to the CssStyleCollection.

class ExtendedStyle : Style
{
    private Dictionary<System.Web.UI.HtmlTextWriterStyle, string> extendedAttributes;

    public string TextAlign
    {
        get
        {
            return GetAttribute(System.Web.UI.HtmlTextWriterStyle.TextAlign);
        }
        set
        {
            SetAttribute(System.Web.UI.HtmlTextWriterStyle.TextAlign, value);
        }
    }

    private string GetAttribute(System.Web.UI.HtmlTextWriterStyle attribute)
    {
        return (extendedAttributes.ContainsKey(attribute))?extendedAttributes[attribute]:null;
    }

    private void SetAttribute(System.Web.UI.HtmlTextWriterStyle attribute, string value)
    {
        if (value == null)
        {
            extendedAttributes.Remove(attribute);
        }
        else
        {
            extendedAttributes[attribute] = value;
        }
    }

    public ExtendedStyle()
    {
        extendedAttributes = new Dictionary();
    }

    protected override void FillStyleAttributes(System.Web.UI.CssStyleCollection attributes, System.Web.UI.IUrlResolutionService urlResolver)
    {
        base.FillStyleAttributes(attributes, urlResolver);

        foreach (System.Web.UI.HtmlTextWriterStyle attribute in this.extendedAttributes.Keys)
        {
            attributes[attribute] = extendedAttributes[attribute];
        }
    }
}

Which allows me to do the following:

Page.Header.StyleSheet.CreateStyleRule(new ExtendedStyle() { TextAlign = "right" }, this, ".foobar");