Sharing thoughts & Learning…

Converting DataView to DataTable in C#

Consider following code for converting DataView to DataTable in C# DataTable dt = dv.ToTable();// dv = Data View Consider following example public DataTable GetFilterData(DataTable dt) { if (dt != null) { DataView dataView = dt.DefaultView; dataView.RowFilter = filterCondition; //some condition like”: ColumnName like ‘%this%’; dt = dataView.ToTable(); } return dt; }

Preventing / Blocking Page Review after Logout with Forms Authentication

After logging out we can prevent getting previous page or information by doing following things. Add Code to Page Load event: —————————– Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); Or We can use following code Page.Response.AppendHeader(“Cache-Control”, “no-store, no-cache, must-revalidate, post-check=0, pre-check=0”); Add Code to Log out Button: —————————– Session.Abandon(); //Session[“IsLogedIn”] = “0”; //set your session status //Response.Redirect(“set your log […]

Export to pdf ( Create pdf on fly ) using ASP.net and C#

Consider following code for creating pdf document on fly using ASP.net in C#. using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.IO; using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; namespace WebApplication1 { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) […]

How to enable Paging in GridView in ASP.net or Grid View Paging doesn’t work

Do Following steps. –> Set EnablePaging and Sorting Callback = True from Propertise. Set your data source as general way. Now do another extra job for working paging Write down the following code under PageIndexGhanging Event protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { //Create your data set or table as u did GridView1.PageIndex = e.NewPageIndex; […]

Cursor in MS SQL

Using Cursor in MS SQL Server 2005 or 2008 Consider following code for creating cursor declare db_cursor CURSOR for SELECT ItemSLNO FROM P_Return_ItemSLNOTraking where Com_PReturnId_ItemId = @Com_ReceiveId_ItemId OPEN db_cursor FETCH NEXT FROM db_cursor INTO @ItemSLNO WHILE @@FETCH_STATUS = 0 BEGIN SET @SLNO = @SLNO+ ‘,’+ @ItemSLNO FETCH NEXT FROM db_cursor INTO @ItemSLNO END CLOSE db_cursor […]

Cannot access shared files and folders or browse computers

Most of the time I am unable to access shared files and folder from other pc. There is a service named Computer Browser stopped automatically I dont know why. But I found a solution from Microsoft site. Here is the solution: At first do following: ———————- i. Right-click My Computer > then click Manage. ii. […]

ERDBManager

1. Introduction: Welcome to ER DBManager.NET®. This documentation helps you understand ER DBManager.NET® and how to integrate the library into your applications. DBManager is a library that is used to perform database(MS SQL, Oracle, Oledb, Odbc) operation (Connecting DB, Executing Command, Reading Data, Reading Output parameter, Executing DataSet etc) more easily in Microsoft™ .NET Platform. […]

Split in MS SQL SERVER

Here I shall describe about split in MS SQL. There is no built in function for splitting your text, that’s why I am describing two customize function for performing split operation in MS SQL. Split function 1: This function returns table that’s why we can say it table valued function. –select * from fnSplit(‘1,22,333,444,,5555,666’, ‘,’) […]