473,466 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

please help on some general concepts on data c# 2.0 vs2005

AAJ
Hi all

FIRST THE BORING BITS.......

I normally use a Database layer, a Business layer and a GUI layer.

The GUI uses an Object data source to bind to the Business layer which in
turn binds to the database layer. Every thing is great. I can read data,
change data in the grid, update the database, and when the GUI reloads, all
the changes are all present and correct. i.e. the data seems to be persisted
in the physical databse and re read when the pages are refreshed.

In my current case I want to do some thing similar but am unsure of the
concepts I need to follow.

This time, I have manually created a datatable in a dataset (strongly typed
using XML) which forms my database layer (BUT this does not connect to a
physical database, its just a manually programatically creates and populates
the dataset with data)

My business layer connects to this database layer.

As usual, my GUI connects to the business layer and the data is presented in
a gridview.

All this works fine. Data is displayed, I can click on the edit of the
gridview, this allows me to change the data, write the data to my business
layer, which then updates the dataset held in the databse layer. This all
works.

however......

After the update has been performed the GUI refreshes, and my business and
database layers are destroyed and and then re created as the Object Dataset
re initialises itsself and its data.

AND EVENTUALLY THE QUESTION........

What I can't understand is - How do I persist my dataset without writing it
to a database. I just want to keep a dataset live to which my GUI's can
write to and treat as though they were a true database datatable, throughout
the lifetime of a client being connected.

hope someone can help,

many thanks

Andy

P.s. I know I can use a viewstate etc on my GUI, but I want the database
layer itsself to manage its own perstistance, so please help, there must be
some pattern or tutorial out there.
Nov 3 '06 #1
5 1361
Hi AAJ,

First question:
After the update has been performed the GUI refreshes, and my business and
database layers are destroyed and and then re created as the Object
Dataset re initialises itsself and its data.
Why??? This seems like an enormous waste of system resources, destroying and
re-creating your business and database layers with each refresh of the UI.
Are you talking about an ASP.Net app by any chance?
AND EVENTUALLY THE QUESTION........

What I can't understand is - How do I persist my dataset without writing
it to a database.
The answer is not easy to say without more information. Where did you get
the data to populate the DataSet from in the first place? Regardless of
whether it comes from a database or not, it has to come from *somewhere*.
And that would logically be the place to store the changes.

--
HTH,

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.
"AAJ" <a.a.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi all

FIRST THE BORING BITS.......

I normally use a Database layer, a Business layer and a GUI layer.

The GUI uses an Object data source to bind to the Business layer which in
turn binds to the database layer. Every thing is great. I can read data,
change data in the grid, update the database, and when the GUI reloads,
all the changes are all present and correct. i.e. the data seems to be
persisted in the physical databse and re read when the pages are
refreshed.

In my current case I want to do some thing similar but am unsure of the
concepts I need to follow.

This time, I have manually created a datatable in a dataset (strongly
typed using XML) which forms my database layer (BUT this does not connect
to a physical database, its just a manually programatically creates and
populates the dataset with data)

My business layer connects to this database layer.

As usual, my GUI connects to the business layer and the data is presented
in a gridview.

All this works fine. Data is displayed, I can click on the edit of the
gridview, this allows me to change the data, write the data to my business
layer, which then updates the dataset held in the databse layer. This all
works.

however......

After the update has been performed the GUI refreshes, and my business and
database layers are destroyed and and then re created as the Object
Dataset re initialises itsself and its data.

AND EVENTUALLY THE QUESTION........

What I can't understand is - How do I persist my dataset without writing
it to a database. I just want to keep a dataset live to which my GUI's can
write to and treat as though they were a true database datatable,
throughout the lifetime of a client being connected.

hope someone can help,

many thanks

Andy

P.s. I know I can use a viewstate etc on my GUI, but I want the database
layer itsself to manage its own perstistance, so please help, there must
be some pattern or tutorial out there.


Nov 3 '06 #2
Use singleton pattern

You would create one instance of a class then use that instance to bring you
the dataset to any of your GUI forms.
Example would be:

public class MySingleton
{
private static MySingleton mObj;

private Dataset mDataset;

private MySingleton()
{
// intitalise your dataset here
mDataset = new Dataset();
}

public static MySingleton Instance
{
get
{
if(mObj == null) // only one instance is created
mObj = new MySingleton();

return mObj;
}
}

public Dataset MyDataset
{
get { return mDataset; }
}
}
then in your code you would use the singleton like

private void PopulateGui()
{
dataGridView1.Datasource = .MySingleton.Instance.MyDataset;
...
}
hope this helps
Fitim Skenderi

"AAJ" <a.a.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi all

FIRST THE BORING BITS.......

I normally use a Database layer, a Business layer and a GUI layer.

The GUI uses an Object data source to bind to the Business layer which in
turn binds to the database layer. Every thing is great. I can read data,
change data in the grid, update the database, and when the GUI reloads,
all the changes are all present and correct. i.e. the data seems to be
persisted in the physical databse and re read when the pages are
refreshed.

In my current case I want to do some thing similar but am unsure of the
concepts I need to follow.

This time, I have manually created a datatable in a dataset (strongly
typed using XML) which forms my database layer (BUT this does not connect
to a physical database, its just a manually programatically creates and
populates the dataset with data)

My business layer connects to this database layer.

As usual, my GUI connects to the business layer and the data is presented
in a gridview.

All this works fine. Data is displayed, I can click on the edit of the
gridview, this allows me to change the data, write the data to my business
layer, which then updates the dataset held in the databse layer. This all
works.

however......

After the update has been performed the GUI refreshes, and my business and
database layers are destroyed and and then re created as the Object
Dataset re initialises itsself and its data.

AND EVENTUALLY THE QUESTION........

What I can't understand is - How do I persist my dataset without writing
it to a database. I just want to keep a dataset live to which my GUI's can
write to and treat as though they were a true database datatable,
throughout the lifetime of a client being connected.

hope someone can help,

many thanks

Andy

P.s. I know I can use a viewstate etc on my GUI, but I want the database
layer itsself to manage its own perstistance, so please help, there must
be some pattern or tutorial out there.


Nov 3 '06 #3
AAJ
Hi Kevin

You've hit the nail on my head, its not by choice but due to my non
understanding, i.e. when my gui says something like

myBusinessLayer newlayer = new myBusinessLayer ();

then won't everything within 'newlayer' will be destroyed and recreated if
the page refreshes. (including the contents of it). This means that the
class has to be recreated and repopulated from the data base every time the
user changes page. The only way I can keep all the contents of newlayer
alive is by adding it to a viewstate and re copying it back in if !PostBack,
using cookies etc...

The second question you asked, is that the data initially comes from an
Excel spread sheet, and I don't want to use this to perstist the data. What
I want to do is load the data from the sheet, perform initial validation and
put it in a DataTable within a DataSet (I can do this no problem). The data
is then presented to the user in a grid (no problem), It can be updated (no
problem), but as the page updates, because my page has :-

myBusinessLayer newlayer = new myBusinessLayer ();

the businesslayer is destroyed and recreated and so the dataset is
recreated. Again, I know I could use viewstates, serialisation etc, or write
to my sql server, and re load but this seems a wastefull. What I think I'm
trying to do is populate and hold a dataset on the server side, and keep the
data live regardless of clients refreshing etc.

In a non web app, I would be able to just instantiate the object once and
keep it alive as long as I like, but because web pages seem to be stateless,
I can't figure on how to do it.
I hope all this makes sense, its not so much the specifics i'm struggling
with but the 'bigger picture'.

thanks again

Andy

"Kevin Spencer" <sp**@uce.govwrote in message
news:OF**************@TK2MSFTNGP03.phx.gbl...
Hi AAJ,

First question:
>After the update has been performed the GUI refreshes, and my business
and database layers are destroyed and and then re created as the Object
Dataset re initialises itsself and its data.

Why??? This seems like an enormous waste of system resources, destroying
and re-creating your business and database layers with each refresh of the
UI. Are you talking about an ASP.Net app by any chance?
>AND EVENTUALLY THE QUESTION........

What I can't understand is - How do I persist my dataset without writing
it to a database.

The answer is not easy to say without more information. Where did you get
the data to populate the DataSet from in the first place? Regardless of
whether it comes from a database or not, it has to come from *somewhere*.
And that would logically be the place to store the changes.

--
HTH,

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.
"AAJ" <a.a.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>Hi all

FIRST THE BORING BITS.......

I normally use a Database layer, a Business layer and a GUI layer.

The GUI uses an Object data source to bind to the Business layer which in
turn binds to the database layer. Every thing is great. I can read data,
change data in the grid, update the database, and when the GUI reloads,
all the changes are all present and correct. i.e. the data seems to be
persisted in the physical databse and re read when the pages are
refreshed.

In my current case I want to do some thing similar but am unsure of the
concepts I need to follow.

This time, I have manually created a datatable in a dataset (strongly
typed using XML) which forms my database layer (BUT this does not connect
to a physical database, its just a manually programatically creates and
populates the dataset with data)

My business layer connects to this database layer.

As usual, my GUI connects to the business layer and the data is presented
in a gridview.

All this works fine. Data is displayed, I can click on the edit of the
gridview, this allows me to change the data, write the data to my
business layer, which then updates the dataset held in the databse layer.
This all works.

however......

After the update has been performed the GUI refreshes, and my business
and database layers are destroyed and and then re created as the Object
Dataset re initialises itsself and its data.

AND EVENTUALLY THE QUESTION........

What I can't understand is - How do I persist my dataset without writing
it to a database. I just want to keep a dataset live to which my GUI's
can write to and treat as though they were a true database datatable,
throughout the lifetime of a client being connected.

hope someone can help,

many thanks

Andy

P.s. I know I can use a viewstate etc on my GUI, but I want the database
layer itsself to manage its own perstistance, so please help, there must
be some pattern or tutorial out there.



Nov 6 '06 #4
AAJ
Hi Fitim

Thanks for the response and the idea, I'll have a good look today. The
question I've got initially though, is if I understand correctly, it will
allow the creation of a single instance, but will the instance (and the
data) remain live between page refreshes, postbacks etc?

thanks again

Andy
"fitim skenderi" <fi****@hotmail.comwrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
Use singleton pattern

You would create one instance of a class then use that instance to bring
you the dataset to any of your GUI forms.
Example would be:

public class MySingleton
{
private static MySingleton mObj;

private Dataset mDataset;

private MySingleton()
{
// intitalise your dataset here
mDataset = new Dataset();
}

public static MySingleton Instance
{
get
{
if(mObj == null) // only one instance is created
mObj = new MySingleton();

return mObj;
}
}

public Dataset MyDataset
{
get { return mDataset; }
}
}
then in your code you would use the singleton like

private void PopulateGui()
{
dataGridView1.Datasource = .MySingleton.Instance.MyDataset;
...
}
hope this helps
Fitim Skenderi

"AAJ" <a.a.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>Hi all

FIRST THE BORING BITS.......

I normally use a Database layer, a Business layer and a GUI layer.

The GUI uses an Object data source to bind to the Business layer which in
turn binds to the database layer. Every thing is great. I can read data,
change data in the grid, update the database, and when the GUI reloads,
all the changes are all present and correct. i.e. the data seems to be
persisted in the physical databse and re read when the pages are
refreshed.

In my current case I want to do some thing similar but am unsure of the
concepts I need to follow.

This time, I have manually created a datatable in a dataset (strongly
typed using XML) which forms my database layer (BUT this does not connect
to a physical database, its just a manually programatically creates and
populates the dataset with data)

My business layer connects to this database layer.

As usual, my GUI connects to the business layer and the data is presented
in a gridview.

All this works fine. Data is displayed, I can click on the edit of the
gridview, this allows me to change the data, write the data to my
business layer, which then updates the dataset held in the databse layer.
This all works.

however......

After the update has been performed the GUI refreshes, and my business
and database layers are destroyed and and then re created as the Object
Dataset re initialises itsself and its data.

AND EVENTUALLY THE QUESTION........

What I can't understand is - How do I persist my dataset without writing
it to a database. I just want to keep a dataset live to which my GUI's
can write to and treat as though they were a true database datatable,
throughout the lifetime of a client being connected.

hope someone can help,

many thanks

Andy

P.s. I know I can use a viewstate etc on my GUI, but I want the database
layer itsself to manage its own perstistance, so please help, there must
be some pattern or tutorial out there.



Nov 6 '06 #5
AAJ
I think what I might be looking for is the SessionState facility i've just
stumbled across.

cheers

Andy
"AAJ" <a.a.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
Hi Kevin

You've hit the nail on my head, its not by choice but due to my non
understanding, i.e. when my gui says something like

myBusinessLayer newlayer = new myBusinessLayer ();

then won't everything within 'newlayer' will be destroyed and recreated if
the page refreshes. (including the contents of it). This means that the
class has to be recreated and repopulated from the data base every time
the user changes page. The only way I can keep all the contents of
newlayer alive is by adding it to a viewstate and re copying it back in if
!PostBack, using cookies etc...

The second question you asked, is that the data initially comes from an
Excel spread sheet, and I don't want to use this to perstist the data.
What I want to do is load the data from the sheet, perform initial
validation and put it in a DataTable within a DataSet (I can do this no
problem). The data is then presented to the user in a grid (no problem),
It can be updated (no problem), but as the page updates, because my page
has :-

myBusinessLayer newlayer = new myBusinessLayer ();

the businesslayer is destroyed and recreated and so the dataset is
recreated. Again, I know I could use viewstates, serialisation etc, or
write to my sql server, and re load but this seems a wastefull. What I
think I'm trying to do is populate and hold a dataset on the server side,
and keep the data live regardless of clients refreshing etc.

In a non web app, I would be able to just instantiate the object once and
keep it alive as long as I like, but because web pages seem to be
stateless, I can't figure on how to do it.
I hope all this makes sense, its not so much the specifics i'm struggling
with but the 'bigger picture'.

thanks again

Andy

"Kevin Spencer" <sp**@uce.govwrote in message
news:OF**************@TK2MSFTNGP03.phx.gbl...
>Hi AAJ,

First question:
>>After the update has been performed the GUI refreshes, and my business
and database layers are destroyed and and then re created as the Object
Dataset re initialises itsself and its data.

Why??? This seems like an enormous waste of system resources, destroying
and re-creating your business and database layers with each refresh of
the UI. Are you talking about an ASP.Net app by any chance?
>>AND EVENTUALLY THE QUESTION........

What I can't understand is - How do I persist my dataset without writing
it to a database.

The answer is not easy to say without more information. Where did you get
the data to populate the DataSet from in the first place? Regardless of
whether it comes from a database or not, it has to come from *somewhere*.
And that would logically be the place to store the changes.

--
HTH,

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.
"AAJ" <a.a.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>Hi all

FIRST THE BORING BITS.......

I normally use a Database layer, a Business layer and a GUI layer.

The GUI uses an Object data source to bind to the Business layer which
in turn binds to the database layer. Every thing is great. I can read
data, change data in the grid, update the database, and when the GUI
reloads, all the changes are all present and correct. i.e. the data
seems to be persisted in the physical databse and re read when the pages
are refreshed.

In my current case I want to do some thing similar but am unsure of the
concepts I need to follow.

This time, I have manually created a datatable in a dataset (strongly
typed using XML) which forms my database layer (BUT this does not
connect to a physical database, its just a manually programatically
creates and populates the dataset with data)

My business layer connects to this database layer.

As usual, my GUI connects to the business layer and the data is
presented in a gridview.

All this works fine. Data is displayed, I can click on the edit of the
gridview, this allows me to change the data, write the data to my
business layer, which then updates the dataset held in the databse
layer. This all works.

however......

After the update has been performed the GUI refreshes, and my business
and database layers are destroyed and and then re created as the Object
Dataset re initialises itsself and its data.

AND EVENTUALLY THE QUESTION........

What I can't understand is - How do I persist my dataset without writing
it to a database. I just want to keep a dataset live to which my GUI's
can write to and treat as though they were a true database datatable,
throughout the lifetime of a client being connected.

hope someone can help,

many thanks

Andy

P.s. I know I can use a viewstate etc on my GUI, but I want the database
layer itsself to manage its own perstistance, so please help, there must
be some pattern or tutorial out there.




Nov 6 '06 #6

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

Similar topics

6
by: Andreas Pauley | last post by:
Hi All, Our company is currently evaluating Python as a language for writing financial/accounting type software (among others). What libraries or packages are available in this domain for use?...
1
by: Az Tech | last post by:
Hi people, (Sorry for the somewhat long post). I request some of the people on this group who have good experience using object-orientation in the field, to please give some good ideas for...
1
by: Top Spin | last post by:
I have been fooling around with Access on and off for a couple of years -- mostly simple applications with only a few tables and simple relationships. I know the basics for the most part and I have...
59
by: Alan Silver | last post by:
Hello, This is NOT a troll, it's a genuine question. Please read right through to see why. I have been using Vusual Basic and Classic ASP for some years, and have now started looking at...
10
by: Harley | last post by:
Hello, I was VERY blessed with a Christmas gift of visual studio .net from a man I hardly know who had heard of my plans of software developement. So I am probably the only person in the world who...
10
by: Rob Dob | last post by:
Hi, I'm amazed!!! I am using VS2005, I create a new web project, c# and then within the default.aspx form right mouse click and select "View Compnent Designer" , I then select and drag a...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
10
by: Jerry | last post by:
I have just started to do some semi-serious programming (not one-off specialized scripts) and am loving Python. I just seem to get most of the concepts, the structure, and the classes (something I...
6
by: djc | last post by:
I had previously (in asp.net 1.1 and asp.net web matrix) just done this to populate a listbox with data from a database: ------------ this was from the page load event ---------------- 'fill...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
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...

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.