How to store dataset

P

Peter Afonin

Hello,

I've been working with .Net for a long time, but always with Asp.Net, I'm
just starting tp work with the Windows forms.

The problem I'm facing now - how to store a dataset between sessions? Is
there something similar to the Session object in Asp.Net?

I was trying to play with the scope of variable and declare a dataset on the
procedure level or module level. In some cases it worked for me, in some -
not. I'm using the windows form to print Crystal reports, and sometimes I
print multiple reports, so I want to keep the dataset between printing
sessions, sometimes I print single reports one by one, so I need to destroy
the dataset after each print. If I declare the dataset on the module level
and then destroy it after printing - it doesn't work, it still exists, so it
works for printing multiple reports, but not singles. If I declare on the
procedure level - it works for the single prints, but not multiple.

I finally managed to solve this, but with lots of code. Is there something
more flexible, similar to the Session object in ASP.NET, that I can create
or destroy at any time?

I would appreciate your help.

Thank you,

Peter
 
S

Scott M.

The concept of s "session" type variable is not relevant in a Windows app.
All you need to do is declare it with the correct accessiblity (private,
protected, friend, protected friend, public).

To keep a DataSet around for a while so that you can get back to it later,
you could declare it at the module level with the Public or Friend keywords.
When you are ready to "destroy" it, you can simply set it to "Nothing" in VB
..NET or "null" in C#. You'll, of course, have to re-assign the variable
back to a valid DataSet to be able to use it after that point.

-Scott
 
P

Peter Afonin

Thank you, Scott, I'll try.

Peter

Scott M. said:
The concept of s "session" type variable is not relevant in a Windows app.
All you need to do is declare it with the correct accessiblity (private,
protected, friend, protected friend, public).

To keep a DataSet around for a while so that you can get back to it later,
you could declare it at the module level with the Public or Friend
keywords. When you are ready to "destroy" it, you can simply set it to
"Nothing" in VB .NET or "null" in C#. You'll, of course, have to
re-assign the variable back to a valid DataSet to be able to use it after
that point.

-Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top