ASP.NET(vb.net) & Session (DataSet & DataTable) This is the guideline/example scripts how to create DataSet,DataTable and use Sesssion DataSet and DataTable.
ShotDev Focus:
- ASP.NET(vb.net) & Session (DataSet & DataTable)
Example
DataSetDataTableSession.aspx
<%@ Import Namespace="System.Data"%> <%@ Import Namespace="System.Data.OleDb"%> <%@ Page Language="VB" %> <script runat="server"> Dim objConn As New System.Data.OleDb.OleDbConnection Dim objCmd As New System.Data.OleDb.OleDbCommand Dim dtAdapter As New System.Data.OleDb.OleDbDataAdapter Dim ds As New DataSet Dim dt As DataTable Dim strConnString,strSQL As String strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("database/mydatabase.mdb")&";Jet OLEDB:Database Password=;" strSQL = "SELECT * FROM customer" objConn.ConnectionString = strConnString With objCmd .Connection = objConn .CommandText = strSQL .CommandType = CommandType.Text End With dtAdapter.SelectCommand = objCmd dtAdapter.Fill(ds) dt = ds.Tables(0) Session("mySession") = dt dtAdapter = Nothing objConn.Close() objConn = Nothing '*** BindData to Control ***' Dim dt2 As DataTable dt2 = Session("mySession") IF Not IsNothing(Session("mySession")) Then Me.myDataGrid.DataSource = dt2 Me.myDataGrid.DataBind() End IF </script>