Improving performances in sql server when join large varchar columns

I have a database with a table that contains a column called pageData of type nvarchar(3000), my problem is that periodically I need to check another db that have a similar table and I need to make a join between the two tables on pageData column. The problem is that a column of nvarchar(3000) cannot be indexed, so the join is too slow.

A possible solution is to include a extended stored procedure to compute the Md5 of a string, apossible approach can be found here. Before joining the two table I compute the md5 value of column pageData in another column that now is indexed because is a char(32) type, and then make the join. The result is much faster than the older join.

Alk.

Today is not a good day :(

Today is not a good day for a couple of reasons, but now my visual studio instance begins to behave in a strange manner, when I digit ALT+126 to make tilde character in a code windows, a strange chars appears instead of tilde, and the font of the visual studio changes, here how it looks like on my monitor

In every other window ALT+126 works as expected (~), mah……………

Alk.

Change style of user controls with css

Thanks to Guardian for the suggestion on this tip, I’m not really a stylesheet guru :D.
The problem is this, I have an ASP.NET user control and I want to show it with two different styles in the same page. I looked into some asp.net forums and I found some examples of peoples that changes SkinId at runtime or did some other tricks, but a much better solution is to use css. In code Example attached to this post I show how to format single instances of user control with the only support of css. First of all This is the code of my user control, a simple label with a textbox.

<asp:Label ID=”Label1″ runat=”server” Text=”Description” CssClass=”labelDefault” />
<
asp:TextBox ID=”TextBox1″ runat=”server” CssClass=”textboxDefault” />

As you can see I simply use a style labelDefault for the label and a textboxDefault for the textbox. For my site the default aspect is red so I use this base css.

.labelDefault 
{
    color: #FF0000;
    font-weight:lighter;
}

.textboxDefault 
{
    border-color:#FF0000;
    border-width: 2;
}

Nothing special :D. Now my objective is to create a page with an instance of this user control with default red style and another instance with a different style that will show everything in blue color. The code of the aspx page is the following.

<div>
<
uc1:MyControl ID=”MyControl1″ runat=”server”></uc1:MyControl>
</
div>
<
div class=”bluestyle”>
<
uc1:MyControl ID=”MyControl2″ runat=”server”></uc1:MyControl>
</
div>

As you can see I simply enclose the second instance of the user control in a div with a style called bluestyle. Now here is the magic part, the css styles to format only the second instance of user control:

.bluestyle .labelDefault 
{
    color: #0000FF;
    font-weight:lighter;
}

.bluestyle .textboxDefault 
{
    border-color:#0000FF;
    border-width: 2;
}

It works as following, let’s consider the first style called .bluestyle .labeldefault, since it has a double name it
will be applied to every object that satisfies these two conditions: has the labelDefault style applied and is enclosed in an object with style bluestyle. With this technique you can change the style of a user control simply enclosing in a div with different css style, this result is achieved only with the use of css styles, no SkinId, no procedural code and no strange tricks :D.

Alk.

 
Â

 Â

WatiN and weird names of asp.net controls

Asp.Net gives to HTML controls weird names, composed by the hierarchy of control used to generate the page. This causes problems for example writing WatiN test, because we cannot use Find.ById or use the Id of the control, because if we will change the layout of the page the name of the controls will change.

One of the possible solution is to use regular expression, using a regex that will search for controls that ends with a specific string value. To easy the use of this method we can realize a simple helper class.

public class AspNetControlFinder : WatiN.Core.Attribute {
 
   
public AspNetControlFinder(String controlName)
      : 
base(“id”, new System.Text.RegularExpressions.Regex(“.*” + controlName)) {
   }
 
   
public static AspNetControlFinder Find(String controlName) {
      
return new AspNetControlFinder(controlName);
   }
}  
This is really a simple class that inherits from Attribute class of WatiN library, that supports natively the option to search with regular expression. Our class has a simple constructor that accepts control name, it calls base constructor telling Attribute class to search for “id” addribute and use a regex “.*”+controlName that simply means Any control whose id ends with controlName. We include a Factory Method to make this class more usable. Now we can write this test

browser.TextField(AspNetControlFinder.Find(“TextBox1”)).TypeText(“19”);

The syntax is very straightforward and it works J

Alk.