jueves, 28 de febrero de 2008

How to use OPENXML in Transact-SQL


DECLARE @idoc int;
DECLARE @xml varchar(max);

EXEC sp_xml_preparedocument @idoc OUTPUT, @xml;
SELECT afield FROM OPENXML(@idoc, '/anodename/.../anodename[@anattribute="..."]/.../anodename[@anattribute="..."]', 1) WITH (afield int);
EXEC sp_xml_removedocument @idoc;

martes, 26 de febrero de 2008

T-SQL Cursors (autoreminder)


DECLARE thecursor CURSOR FOR SELECT ...;
OPEN thecursor;
FETCH NEXT FROM thecursor INTO @thevariable;
WHILE @@FETCH_STATUS = 0
BEGIN
...
FETCH NEXT FROM thecursor INTO @thevariable;
END
CLOSE thecursor;
DEALLOCATE thecursor;

domingo, 24 de febrero de 2008



Which Office Character Are You?

You are part Michael. Deep down, you are caring and good-natured, but you often express yourself in insensitive ways. Though you always try your hardest to make your talents be seen, you could use a little more self-awareness to avoid being awkward.
You are part Jim. You are personable, easy-going, and always socially aware. Your great sense of humor and impishness soften the blow of what might otherwise be a dark, cutting cynicism.
Find Your Character @ BrainFall.com

Customizing BoundField

This is a way to customize BoundField, to be able to support multiline textbox.


Namespace System.Web.UI.WebControls
Public Class MultilineField
Inherits BoundField

Private m_Rows As Integer

Public Property Rows() As Integer
Get
Return m_Rows
End Get
Set(ByVal value As Integer)
m_Rows = value
Me.OnFieldChanged()
End Set
End Property

Protected Overrides Function CreateField() As DataControlField
Return New MultilineField
End Function

Protected Overrides Sub InitializeDataCell(ByVal cell As DataControlFieldCell, ByVal rowState As DataControlRowState)
MyBase.InitializeDataCell(cell, rowState)
If (rowState And DataControlRowState.Insert) Or (rowState And DataControlRowState.Edit) And (Me.DataField <> "") Then
With CType(cell.Controls(0), TextBox)
.TextMode = TextBoxMode.MultiLine
.Rows = Me.Rows
End With
End If
End Sub
End Class
End Namespace