473,883 Members | 2,518 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to read DataSet that is stored in Session

This has to be easy...

I have a DataSet stored in the Session object. I simply need to read it
later and get the following error:
Cannot implicitly convert type 'object' to 'System.Data.Da taSet'

From a code-behind module of an ASPX page, how do I read the contents of a
DataSet that is stored in the Session?

Thanks in advance.
Nov 18 '05 #1
5 7785
Hi,

I assume you are either using C# or VB.NET with the Option Strict On
setting.
In either case, when retieving the DataSet from the session, you will need
to cast the result.

For C#
ds = (DataSet)Sessio n["YourKeyHer e"];

For VB.NET (Option Strict On)

ds = CType( Session("YourKe yHere"), DataSet )
or
ds = DirectCast( Session("YourKe yHere"), DataSet )

Hope this helps

--
Chris Taylor
http://dotnetjunkies.com/WebLog/chris.taylor/
"Guadala Harry" <gh****@aol.com > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
This has to be easy...

I have a DataSet stored in the Session object. I simply need to read it
later and get the following error:
Cannot implicitly convert type 'object' to 'System.Data.Da taSet'

From a code-behind module of an ASPX page, how do I read the contents of a
DataSet that is stored in the Session?

Thanks in advance.

Nov 18 '05 #2
Never mind - it is easy - provided that ZoneAlarm is not running... I forgot
that when ZoneAlarm is running, every request for a new page results in the
Session getting blown away and re-initialized. My conversion from object to
DataSet failed because the (new) Session didn't have any DataSet to convert.

G

"Guadala Harry" <gh****@aol.com > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
This has to be easy...

I have a DataSet stored in the Session object. I simply need to read it
later and get the following error:
Cannot implicitly convert type 'object' to 'System.Data.Da taSet'

From a code-behind module of an ASPX page, how do I read the contents of a
DataSet that is stored in the Session?

Thanks in advance.

Nov 18 '05 #3
Hi, Guadala Harry,

You need to cast the instance to DataSet:

[C#]
DataSet foo = (DataSet)Sessio n["foo"];

[VB.NET]
DataSet foo = CType(Session(" foo"), DataSet)

Greetings
Martin
"Guadala Harry" <gh****@aol.com > wrote in message
news:#h******** ******@TK2MSFTN GP10.phx.gbl...
This has to be easy...

I have a DataSet stored in the Session object. I simply need to read it
later and get the following error:
Cannot implicitly convert type 'object' to 'System.Data.Da taSet'

From a code-behind module of an ASPX page, how do I read the contents of a
DataSet that is stored in the Session?

Thanks in advance.

Nov 18 '05 #4
Thanks for all your helpful responses.

Chips and Salsa for EVERYONE!

"Guadala Harry" <gh****@aol.com > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
This has to be easy...

I have a DataSet stored in the Session object. I simply need to read it
later and get the following error:
Cannot implicitly convert type 'object' to 'System.Data.Da taSet'

From a code-behind module of an ASPX page, how do I read the contents of a
DataSet that is stored in the Session?

Thanks in advance.

Nov 18 '05 #5
You have toc ast it out to the corretc type you stored it as......

Read this

http://msdn.microsoft.com/library/de...us/dv_vbcode/h
tml/vbtskcodecachin gdatasetvisualb asic.asp

and this

http://msdn.microsoft.com/library/de...us/vbcon/html/
vbconDecidingOn DataAccessStrat egy.asp

Also, you should look at storing cached data in the cache object ......

Regards

John Timney
Microsoft Regional Director
Microsoft MVP

"Guadala Harry" <gh****@aol.com > wrote in message
news:#h******** ******@TK2MSFTN GP10.phx.gbl...
This has to be easy...

I have a DataSet stored in the Session object. I simply need to read it
later and get the following error:
Cannot implicitly convert type 'object' to 'System.Data.Da taSet'

From a code-behind module of an ASPX page, how do I read the contents of a
DataSet that is stored in the Session?

Thanks in advance.

Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1449
by: Frank Rizzo | last post by:
Hello. Every now and then (it's rare), i get an exception when calling SqlDataAdapter.Fill. The code is calling a stored procedure and attempts to stuff the results into a dataset. It yields the following exception. I am trying to understand what the exception is actually complaining about. Is it a problem with the data that came back or is it an issue inside the stored procedure? Any alternative ways to nail down this issue would...
2
3391
by: John Holmes | last post by:
I have a web interface where the user types in ID's one at a time. After an ID is typed in, a button is clicked and the button click event has code that does a query and returns a data reader and then appends the data to a dataset that is built in the Page_Load code in the if(!isPostBack) block. When I try to add a row in the button click event code I get an error saying that "Object reference not set to an instance of an object". I'm...
2
1642
by: Martin | last post by:
Hi! I'm new to ASP.NET WebApplications and wonder whether I've missed something out when programming it. I'm grateful for any hints to this problem! Thanks very much for your efforts! Martin Description:
3
2214
by: Arthur Dzhelali | last post by:
Is there any way to cache dataset on one page and it will be accessible for one user? if you declare dataset shared it will stay on the server and page will be able reference to it on reload, but in this case it will be shared with other users who use the page. Right now I found work around it by saving each dataset as xml file with users's sessionid in file name and reading it on page reload. is there a better way?
1
2922
by: Henry | last post by:
Hi. I've been trying to modify my dataset and have been unsucessful. Any help would be great. What I have is a dataset in a session variable. Here is what I have done to stored into the dataset via store procedure. Sample Stored Procedure: CREATE PROCEDURE prcGetData AS
0
1098
by: Czar Eclarinal | last post by:
Hi Everyone, I've declared a datatable out of my typed dataset stored in session and add a new row to it. When state management is set to InProc and I modified the declared dataable, the changes reflect to the dataset. But when the session is OutProc (using SQL) , the changes doesnt reflect. For e.g. Sub Page_Load myDataSet AS myTypedDataSet
4
2200
by: Huw Lloyd | last post by:
I have developed a windows application in VB.NET and now want to take parts of it and put it on the web, so although I understand all about datasets etc, I know little about web development My issue is that I have a grid bound to a dataset, and I have a text box under the grid where users can enter a new value. They then click the ADD button and I want the result to be added to the dataset and thus appear in the grid. When the user first...
1
2417
by: whidbey | last post by:
Hello friends, I am whidbey, new to thescripts and dot net as well.I am working over Online Shopping Cart,web application.I design a page (webform5.aspx) where user search books then select the books to buy from the datagrid. User can select books using checkboxes in the datagrid. The selected books are stored in a session variable name session("temp") which is a dataset type.After storing dataset in session (in bold letters),user will...
0
2001
by: whidbey | last post by:
Hello friends, I am whidbey, new to thescripts and dot net as well.I am working over Online Shopping Cart,web application.I design a page (webform5.aspx) where user search books then select the books to buy from the datagrid. User can select books using checkboxes in the datagrid. The selected books are stored in a session variable name session("temp") which is a dataset type.After storing dataset in session (in bold letters),user will...
0
9953
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9799
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10768
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10868
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10422
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9588
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7980
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4231
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.