Thursday, June 21, 2007

SQL: NULL in database.

Today a new company trainee just remind me one thing when I try to compare a string with null values.

NULL in Database is not a value.

Yes right. In SQL NULL is treated as UNKNOWN value, which is different from empty string. So if you want to compare with NULL, you need to use "IS" or "IS NOT" statement. (keep reminding myself)

Luckly SQL has an extension to overcome this problem.

If you really want to compare NULL with a "=" or "<" or "<>" or ">" as a value. You can set the ANSI_NULLS to OFF.

For me personally I am a C# person. I am more likely to use "=" signs in store procedures.

However in simple testing query. I may be just "IS" or "IS NOT"

Error Handling: String VS StringBuilder

I am trying to output a format string to display. Then I came across an error. Hope you guys can advoid it.

As you may all know StringBuilder has performance advantages over complex string.
So what's the different between
String.Format
and
StringBuilder.AppendFormat

I've found it if the args number is not correct in string builder it will throw the following exception while string will not.

Error: {"Index (zero based) must be greater than or equal to zero and less than the size of the argument list." }



--
Cheers,

Gary

Wednesday, June 06, 2007

How to setup ActiveReport display footer only on the first page?

I am using Active Report 2.0. I try to display one of the footer object just display on the first page.

I found out a way to do it. To use the PageEnd event.
In the page end event, which is ending event of ever page generated.
so I need to write my code like this.

            if (this.PageNumber > 0 )
            {
               ABCTextBox.Visible=false;
            }


the next ABCTextBox visibility is set. Thus, I will only have this text box in the first page.