473,320 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

dataset can not be shared across subs

Hi,
I declared a dataset outside any subs, then I fill the dataset with a
tables in a Private Sub1, then I want to take the data out from the dataset
in Sub2.
like .
sub2()
datagrid.datasource=ds.tables("t").defautview
datagrid.databind()
end sub

but it goes wrong. if I show the tables the datagrid in the sub where the
dataset is fill with SQLdataAdapter, it is OK.

I remmebered dataset is in memory, can I shared the dataset in different
Subs?

thanx.
Nakhi
Lijiang,Yunnan,China
Nov 17 '05 #1
2 1478
remember the web is stateless so as soon as you post back from the server
your data is gone which is why it doesn't work outside of the sub. what you
will need to do is hold the data somewhere and get it when you need to
consider
Session["STORE"] = ds from sub 1
in sub 2
DataSet ds = new DataSet();
if(Session["STORE"] != null)
ds = (DataSet)Session["STORE"];
"nakhi" <na***@sina.com> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
Hi,
I declared a dataset outside any subs, then I fill the dataset with a
tables in a Private Sub1, then I want to take the data out from the dataset in Sub2.
like .
sub2()
datagrid.datasource=ds.tables("t").defautview
datagrid.databind()
end sub

but it goes wrong. if I show the tables the datagrid in the sub where the
dataset is fill with SQLdataAdapter, it is OK.

I remmebered dataset is in memory, can I shared the dataset in different
Subs?

thanx.
Nakhi
Lijiang,Yunnan,China

Nov 17 '05 #2
thanx,I filled the dataset in Sub Page_load(), so it is run in every
request, and I can share the dataset in any subs.

Nakhi

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > дÈëÓʼþ
news:Op*************@tk2msftngp13.phx.gbl...
remember the web is stateless so as soon as you post back from the server
your data is gone which is why it doesn't work outside of the sub. what you will need to do is hold the data somewhere and get it when you need to
consider
Session["STORE"] = ds from sub 1
in sub 2
DataSet ds = new DataSet();
if(Session["STORE"] != null)
ds = (DataSet)Session["STORE"];
"nakhi" <na***@sina.com> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
Hi,
I declared a dataset outside any subs, then I fill the dataset with a
tables in a Private Sub1, then I want to take the data out from the

dataset
in Sub2.
like .
sub2()
datagrid.datasource=ds.tables("t").defautview
datagrid.databind()
end sub

but it goes wrong. if I show the tables the datagrid in the sub where the dataset is fill with SQLdataAdapter, it is OK.

I remmebered dataset is in memory, can I shared the dataset in different Subs?

thanx.
Nakhi
Lijiang,Yunnan,China


Nov 17 '05 #3

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

Similar topics

14
by: antonyliu2002 | last post by:
I am new to .NET framework. A bunch of web pages of mine need the same function. Right now, I put the Subs in each individual page. I think there must be a way to save my Subs in a separate...
2
by: John Granade | last post by:
I'm looking for the best way to make a dataset available from multiple Windows forms. The dataset is created from an XML file. I have a main form (frmMain) that loads the dataset and reads the...
4
by: a | last post by:
Hello Gang, I am in a bit of confusion regarding a half completed application I am writing. It is an MDI app, so I have a main form (frmMain) that is always open. I am looking for a 'Best...
4
by: Rubbrecht Philippe | last post by:
Hi there, I would like to develop an interface that when implemented in a class requires a number of shared properties or methods to be available. It seems a Shared Member can not be used as...
0
by: ~J~ | last post by:
Hi, I really hope someone can help me out here. In relation to this thread ( http://www.thescripts.com/forum/thread349557.html ) I'm having a similar issue and getting nowhere fast! In a...
3
by: Jeff | last post by:
....still new to vb.net and vs 2005 web applications. I remain confused about the "shared" variable/table designation and the difference between "public" etc. I wish to place an entire table from...
8
by: Jeff | last post by:
Still new to vb.net in VS2005 web developer... What is the proper/standard way of doing the following - setting the value of a variable in one sub and calling it from another? E.g., as below....
4
by: Mick Walker | last post by:
Hi All, I am just wondering, is there some sort of overhead involved in shared or static functions and subs? I think there must be, otherwise, there would never be any need to create an...
6
by: JB | last post by:
Hi All, I'm building a DLL that can be used by several applications. I'd like to have one single instance of a Class stored in my DLL that would be ("shared") by all the applications using that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.