Set Auto Increment Value Of Cloumn In SQL Server database

To set the incremental value of a incremental column in a sql server database you have to first insert explicitly. when inserting set the value you want to set. 

SET IDENTITY_INSERT YourTable ON

INSERT INTO YourTAble(AutoIncID, ...other columns....)
VALUES(100, ......)

SET IDENTITY_INSERT YourTable OFF
Advertisements

Get the Enum Type from a Integral Value

In the following example it shows how to retrieve the Enum Type from the integer value. For that we use The Enum Class. In the example i have used a DataSet where ORGANIZATION_TYPE is the column name which contain the integral value and the OrganizationType is the Enum.

foreach (DataRow item in ds.Tables[0].Rows)
    {
        item["ORGANIZATION_TYPE"] = Enum.Parse(typeof(OrganizationType), item["ORGANIZATION_TYPE"].ToString()).ToString();

}

 

MessageBox/Popup


private void DisplayMessages(string message)
{
try
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Popup", "alert('" + message + "');", true);
}
catch (Exception ex)
{
lblError.Text = ex.Message;
}
}

This a message box which displays the messages as a windows popup. When you use this make sure that you are using it for the end of event. Otherwise it wont allow to execute the rest of the code.