Site Meter Asp.Net-Csharp,Asp,Ado.Net,Ado,Micosoft,Visualstudio,Visual webgui: December 2009

Friday, December 11, 2009

Overview and example for Datatable in asp.net

Overview and example for Datatable in asp.net:


MEthod 1:


DataTable cTable = new DataTable();
DataRow d3;

cTable.Columns.Add("A", typeof(string));
cTable.Columns.Add("B", typeof(string));
cTable.Columns.Add("C", typeof(string));

d3 = cTable.NewRow();
d3[0] = "A:";
d3[1] = B;
d3[2] = "C";

cTable.Rows.Add(d3);


Method 2:

DataTable dtProducts = new DataTable();
DataColumn productColumn = new DataColumn();

productColumn.DataType = System.Type.GetType("System.Int32");
productColumn.ColumnName = "id";
productColumn.Unique = true;
dtProducts.Columns.Add(productColumn);


DataTable dtProducts = createProductDT();

DataRow aProduct = dtProducts.NewRow();

aProduct["id"] = 11;
aProduct["thumb"] = "images/widget0.jpg";
aProduct["name"] = "Red Widget";
aProduct["price"] = 19.99;
dtProducts.Rows.Add(aProduct);

Wednesday, December 9, 2009

Types,Modes,Differences of session in asp.net

Overview of session modes and types in asp.net:

Normally http protocol is stateless to maintain state following namespace is used.

System.Web.SessionState.HttpSessionState

Modes And's Provider:

Session State Mode State Provider

InProc In-Memory Object
StateServer Aspnet_state.exe
SQLServer DataBase
Custom CustomProvider

Session Event's:

There are two types of session events available in asp.net

* Session_Start
* Session_End


Types:

1.inproc Mode (ie inprocess)--->Its availble inside the webserver itself not ouside the application.
2.StateserverMode(ie out process) -->Its availble outside the webserver,not inside the application.
3.sqlserver Mode -->To store session datas in sqlserver.AND DATAS CAN BE SHARED BETWEEN OTHE APPLICATIONS.
4.Custom Mode --> To create a manual session id's.



1.inproc Mode

Advantages :

* It store Session data in memory object of current application domain. So accessing data is very fast and data is

easily available.
*Datas not alive when application restarted.
* There is not requirements of serialization to store data in InProc Session Mode.
* Implementation is very easy, just similar to using View State.

DisAdvantage:

If the worker Process or application domain recycles all session data will be lost.


2.StateserverMode

This session state is totally managed by aspnet_state.exe.

This approaches has several disadvantages due to the overhead of serialization and de-serialization.

Datas will be alive it the aspnet services restarted also.


3.sqlserver Mode

The most easiest way to configure SQL Server, is using aspnet_regsql command.

4.Custom Mode --> To create a manual session id's.