Archive for October, 2006

Unlike stored procedures, one cannot simply omit a parameter (with a default) to a Sql Server 2000/2005 user-defined function.  For example, if you had a function such as:

    create function fn_just_do_it(@a varchar(10), @b varchar(10) = ‘xyzzy’)

You would not call it like this:

    select dbo.fn_just_do_it(‘Hi mom’)

Instead, insert the word DEFAULT as a placeholder:

      select dbo.fn_just_do_it(‘Hi mom’, DEFAULT)

From Sql Help:

When a parameter of the function has a default value, the keyword DEFAULT must be specified when calling the function to retrieve the default value. This behavior is different from using parameters with default values in stored procedures in which omitting the parameter also implies the default value.


Read Full Post »

I just received my regular weekly e-mail from Art Morris with a link to an impressive nature photography show by Frans Lanting.   The show is a wonderful collection of nature pictures and music arranged according to the timeline of evolution.   Don’t miss it:  http://www.lifethroughtime.com.

Read Full Post »

We recently needed to add an option to an “extract report” to shift the values on a per row basis depending on criteria within the row.  The report displays remaining payment streams for equipment leases where RP1 represents the next payment owed by the customer.

  Contract #   RP1   RP2   RP3 … RP120

In the current version of the report, RP1 represents the next amount owed on a lease regardless of when it was due.   Our customer wanted to optionally have RP1 represent the same month for all leases.   This requires us to shift each row a certain number of months to the right and have RP1 represent the earliest possible month in the data set. Initially, we considered creating another table in the data warehouse to hold the shift payment streams until we discovered that we could handle the shifting in the actual report using the following function:

Public Function GetValue(allFields as Fields, reportType as string, index as integer) as string
    Dim offset as integer

    offset = 0
    if reportType <> “Standard” then offset = allFields!DueDateOffset.Value    GetValue = “”
    if (index + offset) <= 120 then GetValue = allFields(“RP” + CStr(index + offset)).Value
End Function


The function is called from each the report textboxes:

    =Code.GetValue(Fields, Parameters!ReportType.Value, 5)

The key learning was that the collection of fields can be passed as a parameter and then accessed as an array using the column name as a string index.


Read Full Post »

Windows Live Writer (Beta)

I just downloaded a copy of the new Windows Live Writer beta program because I have not been that happy with the simple HTML editor provided by WordPress.  I have been spending more time than should be necessary to edit posts with sample code snippets in them such as this:

private void Page_Load(object sender, System.EventArgs e)
if (!IsPostBack)

“return confirm(\”Are you sure you want to delete?\”);”);

“return confirm(\”Are you sure you want to cancel?\”);”);

While Windows Live Writer seems to be less glitchy than the WordPress editor, Live Writer also lost my tab indentations when I posted in the text.  Unfortunately, I still need to manually insert the proper indenation (or replace the tabs with spaces before inserting).

Read Full Post »

Another minor ASP.NET 2.0 porting issue.  In 1.1, ASP.NET will not generate a style attribute for an <asp:image> control unless you override one of the default style attributes.  In 2.0, the <asp:image> control will always insert a style element:

    <img id=”i” src=”/p000681.jpg” mce_src=”/p000681.jpg” style=”border-width:0px;” />

This, of course, takes precedence over any settings in your style sheet preventing you from controlling border width formatting using CSS.  

A couple of solutions:

  1. Use a placeholder instead of the <asp:image> control and insert your own IMG html on the fly.
  2. Create your own class which inherits from the WebControls.Image class and eliminates the offending style attribute from the generated html. 

  using System;
  using System.IO;
  using System.Text;
  using System.Web.UI; 
  public class ImagePlus : System.Web.UI.WebControls.Image
    protected override void Render(HtmlTextWriter writer)
      StringWriter sw = new StringWriter();
      HtmlTextWriter localWriter = new HtmlTextWriter(sw);
      string output = sw.ToString();
      output = output.Replace(“style=\”border-width:0px;\””, string.Empty);

You then need to change your ASPX page to use your custom control instead:

<%@ Register TagPrefix=”hgp” Namespace=”…” Assembly=”…” %>

<hgp:ImagePlus id=”imgX” runat=”server”></hgp:ImagePlus>

Any other ideas for working around this issue?

Read Full Post »