CodeWidgets.com Online Source Code Library -ASP, ASP.NET, VB, VB.Net, Microsoft® Access, Javascript, VBScript, Website Design, Web Applications, Custom Programming Services Available.

 CodeWidgets.com ASP, ASP.NET, VB, VB.Net,
Microsoft® Access, Javascript, VBScript,
Website Design, Web Applications
Shopping Cart (0) Items $0.00      
 CodeWidgets.com
CodeWidgets.com

 

Website Stats to Date

Pages Viewed 6,940,643
Visitors 1,664,751
Widgets Viewed 4,483,408
Since January 1/2003
 
 
Active Users: 42
 

 
PayPal: Secure online payments!
 
Widget #CS0197

Storing a DataSet in a Session Variable (ASP.NET)

Storing a DataSet in a Session Variable (ASP.NET)

Send Link

Questions

Currency Conv.
  Widget Info  

Dim DB As New System.Data.OleDb.OleDbConnection()
Dim DA As System.Data.OleDb.OleDbDataAdapter
Dim DS As New System.Data.DataSet()
''WHEN THE PAGE IS LOADED CHECK FOR A VALUE IN THE SESSION VARIABLE
''IF NOT FOUND LOAD THE DATA FROM THE DATABASE AND STORE IT IN A SESSION VARIABLE FOR LATER USE.

If IsNothing(Session("Categories")) Then
DB = Session("DBCon")
Dim SQL As String = "Select * From ProductCategories Order By Category"
DA = New System.Data.OleDb.OleDbDataAdapter(SQL, DB)
DA.Fill(DS)
Session("Categories") = DS
Session("DBCon") = DB
DB.Close()
DB = Nothing
Else
''IF THE SESSION VARIABLE CONTAINS A DATASET THEN DON'T LOAD FROM THE DATABASE
''USING THE DATASET FROM THE SESSION VARIABLE REDUCES DATABASE ACCESS

DS = Session("Categories")
End If
DGrid.DataSource = DS
DGrid.DataBind()

 Licensing
Format: HTML Article
Online Document
Licencing Terms: No Restrictions
Re-Distribution Permitted
This source code is provided to you "as is" without warranty
CLICK HERE FOR TERMS OF USE
Copyright 2002-2006 Comrie Software Solutions
 Related Widgets

Create a "Print Window" button (Javascript)
Create a "Send Link by email" button (Javascript)
Create a function that returns multiple values.
Create a Session Database Connection through code (ASP.NET)

ShoppingCart Empty
Services Contact Info Legal Info
Designated trademarks and brand names are the property of their respective owners.

By accessing this website it is assumed that you agree to the TERMS OF USE.

Send questions or comments regarding this website to  Comrie Software Solutions.

Click here for a complete list of available Widgets.