Tuesday, November 4, 2014

Clean webform cache.

Generally webforms get data from cache while click on browser back button. Following code snippet will cleanout the page cache and doesn't display any previous data even clicking on browser back button.

 Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
        Response.Cache.SetNoStore();
        Response.AppendHeader("Pragma", "no-cache");

Thursday, October 30, 2014

Get output in XML format from sqlserver.

To get an output in XML format from sqlserver , do following steps.
declare @XmlOutput xml
set @XmlOutput = (select top 10 * from table_Name where id=235
FOR XML AUTO, ROOT('Flex'), ELEMENTS)

select @XmlOutput --In place of this if we write the file location then output will be written over there.