473,473 Members | 4,204 Online
Bytes | Software Development & Data Engineering Community
Create 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.DataSet'

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 7763
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)Session["YourKeyHere"];

For VB.NET (Option Strict On)

ds = CType( Session("YourKeyHere"), DataSet )
or
ds = DirectCast( Session("YourKeyHere"), DataSet )

Hope this helps

--
Chris Taylor
http://dotnetjunkies.com/WebLog/chris.taylor/
"Guadala Harry" <gh****@aol.com> wrote in message
news:%2****************@TK2MSFTNGP10.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.DataSet'

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****************@TK2MSFTNGP10.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.DataSet'

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)Session["foo"];

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

Greetings
Martin
"Guadala Harry" <gh****@aol.com> wrote in message
news:#h**************@TK2MSFTNGP10.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.DataSet'

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****************@TK2MSFTNGP10.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.DataSet'

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/vbtskcodecachingdatasetvisualbasic.asp

and this

http://msdn.microsoft.com/library/de...us/vbcon/html/
vbconDecidingOnDataAccessStrategy.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**************@TK2MSFTNGP10.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.DataSet'

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
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...
2
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...
2
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...
3
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,...
1
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...
0
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...
4
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...
1
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...
0
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...
0
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...
1
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...
0
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.