In Query try this:
FOR TOP 5
select top 5 * from table
//——————-
FOR LAST 5
select top 5 * from table order by primarykey_columnname desc
Good Luck
Friday, January 23, 2009
Get Month Name from SQL
Hitry this SQL query to get month name
SELECT ID,datename(month,PostDate) as Month FROM yourTable
where PostDate is field in my table of datetime type
Good Luck
SELECT ID,datename(month,PostDate) as Month FROM yourTable
where PostDate is field in my table of datetime type
Good Luck
Monday, December 15, 2008
Handle Large ViewState Size
Create Class in App_Code called BasePage.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web.UI;
class BasePage : System.Web.UI.Page
{
//Override two relevant methods that handle Loading and Saving of ViewState:
protected override object LoadPageStateFromPersistenceMedium()
{
object viewStateBag;
string m_viewState = (string)Session["ViewState"];
LosFormatter m_formatter = new LosFormatter();
try
{
viewStateBag = m_formatter.Deserialize(m_viewState);
}
catch
{
throw new HttpException("The View State is invalid.");
}
return viewStateBag;
}
protected override void SavePageStateToPersistenceMedium(object viewState)
{
MemoryStream ms = new MemoryStream();
LosFormatter m_formatter = new LosFormatter();
m_formatter.Serialize(ms, viewState);
ms.Position = 0;
StreamReader sr = new StreamReader(ms);
viewStateString = sr.ReadToEnd();
Session["ViewState"] = viewStateString;
ms.Close();
return;
}
}
and make all pages inhrit from BasePage class
Good Luck
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web.UI;
class BasePage : System.Web.UI.Page
{
//Override two relevant methods that handle Loading and Saving of ViewState:
protected override object LoadPageStateFromPersistenceMedium()
{
object viewStateBag;
string m_viewState = (string)Session["ViewState"];
LosFormatter m_formatter = new LosFormatter();
try
{
viewStateBag = m_formatter.Deserialize(m_viewState);
}
catch
{
throw new HttpException("The View State is invalid.");
}
return viewStateBag;
}
protected override void SavePageStateToPersistenceMedium(object viewState)
{
MemoryStream ms = new MemoryStream();
LosFormatter m_formatter = new LosFormatter();
m_formatter.Serialize(ms, viewState);
ms.Position = 0;
StreamReader sr = new StreamReader(ms);
viewStateString = sr.ReadToEnd();
Session["ViewState"] = viewStateString;
ms.Close();
return;
}
}
and make all pages inhrit from BasePage class
Good Luck
Subscribe to:
Posts (Atom)