CodeWidgets.com: Online Source Code Library: C#, ASP, ASP.NET, VB, VB.NET, VB Script, Microsoft Access, Excel, JavaScript, J Script, XML, VBScript, Website Design, DevExpress Components, Reporting, Application and Website Templates.

Widget #CS0197

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

Free

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()

Last Updated: 3/18/2005


Related Widgets 
Price 
# 
No data to display

Recently Viewed Widgets 
Price 
# 
No data to display

Collapse/Expand
Format

HTML Article

Online Document


Collapse/Expand
License

License

No Restrictions

Re-Distribution Permitted
This source code is provided to you "as is" without warranty
CLICK HERE FOR TERMS OF USE
Copyright 2000-2006 Comrie Software Solutions