Thursday, December 3, 2009

Add blank item at the top of dropdownlist

drpList.Items.Insert(0, new ListItem(String.Empty, String.Empty));
drpList.SelectedIndex = 0;


Reference: here

Insert Record into Database via Dataset

Click here

VB.NET Class

If the class inherit another class, you may use the baseclass sub new as follows:
Class ChildClass
Inherits BaseClass
Public Sub New(text As String)
MyBase.New(text)
End Sub
End Class


Reference: Here

More inheritance lessons

Microsoft Enterprise Library Exception Logging error

Did you encounter this error?
The type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' cannot be resolved. Please verify the spelling is correct or that the full type name is provided.

Simply add Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll as the reference to your project.

Reference: here

Tuesday, December 1, 2009

Remove Identity column in a table

Reset Identity in MS SQL

Remove the IDENTITY Property from an Existing Column in SQL Server 2000

Removing IDENTITY from existing column

Subquery sample

create table T3 (a int unique clustered, b int)

insert T1 values(0, 0, 0)
insert T1 values(1, 1, 1)

select
case
when T1.a > 0 then
(select T3.b from T3 where T3.a = T1.b)
else
T1.c
end
from T1


Reference: here

Thursday, July 2, 2009

Append string in front to StringBuilder

Here's how to append string in front for StringBuilder
StringBuilder sb = new StringBuilder();
sb.Append("sample");
sb.Insert(0, "firststring ");
string s = sb.ToString();

Reference: here