use the same dataset in the second form (by reference)

  • Thread starter Thread starter MajorTom
  • Start date Start date
M

MajorTom

Hello everybody,

I need help on how to use the same datase in two different form, this is the
scenario:
at the first form I load a big dataset (ds1) for short, but I not want to
load it again at the second form
at some point I use a second form

Form f = new FormX();
f.ShowDialog();

at the f form I need to use ds1, and I have the same ds1 in the f form

I tried assigning public access for f.ds1
and do like this:

Form f = new FormX();
f.ds1 = this.ds1;
f.ShowDialog();

also I tried passing it at the constructor like this:

Form f = new FormX(ds1);
f.ShowDialog();

all the time the dataset ds1 at the second form have no rows
the only way I get the record is using the merge method this way

Form f = new FormX();
f.ds1.Merge(this.ds1);
f.ShowDialog();

but it take the time for filling the dataset f.ds1 again
the solution that I need is to use the same dataset or at least not take the
time for load it again

Thanks for your help

MajorTom
 
MajorTom,

I think that you are doing something wrong if you have no rows. Can you
show some of the code, or a sample project which shows the problem? You
should just be able to share the data set normally.

Hope this helps.
 
Thanks for your help.

As you say that I just be able to share the dataset normally.
I check for the number of rows at the second form, and found they are there.

the problem was with my control (combobox) that don't display any rows,
datasource and all others necessary proprieties were set, but for a reason I
don't understand now, I have to set the datasource again at the load event
of the second form.

now is working ok, but when I set de datasource of the combobox

this.cboCodControl.DataSource = this.ds1inv_master1.inv_master;

I get almost the same performance problem (this is what I want to avoid),
the dataset is very big and it take some seconds processing that line of
code (or some one related)

I want to make a example project, but have to deal with a lot of SQL tables.

Is the another way for me to get the desired results

Tanks very much

MajorTom


Nicholas Paldino said:
MajorTom,

I think that you are doing something wrong if you have no rows. Can you
show some of the code, or a sample project which shows the problem? You
should just be able to share the data set normally.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

MajorTom said:
Hello everybody,

I need help on how to use the same datase in two different form, this is
the
scenario:
at the first form I load a big dataset (ds1) for short, but I not want to
load it again at the second form
at some point I use a second form

Form f = new FormX();
f.ShowDialog();

at the f form I need to use ds1, and I have the same ds1 in the f form

I tried assigning public access for f.ds1
and do like this:

Form f = new FormX();
f.ds1 = this.ds1;
f.ShowDialog();

also I tried passing it at the constructor like this:

Form f = new FormX(ds1);
f.ShowDialog();

all the time the dataset ds1 at the second form have no rows
the only way I get the record is using the merge method this way

Form f = new FormX();
f.ds1.Merge(this.ds1);
f.ShowDialog();

but it take the time for filling the dataset f.ds1 again
the solution that I need is to use the same dataset or at least not take
the
time for load it again

Thanks for your help

MajorTom
 
Well one thing to consider is this design.

I was writing an application recently that had an incredible amout of lookup
tables, so I needed some sort of dataset that all parts of my app could get
to to implement the combo box's datasource property.

I used a static class that held a series of static DataSets,
this allowed me to get the datasets desired without recreating a new
instance of anything at runtime, :)
Works great, if you would like me to further explain or show you by code
examples let me know, it seems to work well.
I used this technique with creating RecognizerContexts on a TabletApp that
worked well there as well, the RecognizerContext obect is a huge hit , :)
Make one, use it everywhere,

Mark

MajorTom said:
Thanks for your help.

As you say that I just be able to share the dataset normally.
I check for the number of rows at the second form, and found they are
there.

the problem was with my control (combobox) that don't display any rows,
datasource and all others necessary proprieties were set, but for a reason
I
don't understand now, I have to set the datasource again at the load event
of the second form.

now is working ok, but when I set de datasource of the combobox

this.cboCodControl.DataSource = this.ds1inv_master1.inv_master;

I get almost the same performance problem (this is what I want to avoid),
the dataset is very big and it take some seconds processing that line of
code (or some one related)

I want to make a example project, but have to deal with a lot of SQL
tables.

Is the another way for me to get the desired results

Tanks very much

MajorTom


in
message news:eESCEFm#[email protected]...
MajorTom,

I think that you are doing something wrong if you have no rows. Can you
show some of the code, or a sample project which shows the problem? You
should just be able to share the data set normally.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

MajorTom said:
Hello everybody,

I need help on how to use the same datase in two different form, this
is
the
scenario:
at the first form I load a big dataset (ds1) for short, but I not want to
load it again at the second form
at some point I use a second form

Form f = new FormX();
f.ShowDialog();

at the f form I need to use ds1, and I have the same ds1 in the f form

I tried assigning public access for f.ds1
and do like this:

Form f = new FormX();
f.ds1 = this.ds1;
f.ShowDialog();

also I tried passing it at the constructor like this:

Form f = new FormX(ds1);
f.ShowDialog();

all the time the dataset ds1 at the second form have no rows
the only way I get the record is using the merge method this way

Form f = new FormX();
f.ds1.Merge(this.ds1);
f.ShowDialog();

but it take the time for filling the dataset f.ds1 again
the solution that I need is to use the same dataset or at least not
take
the
time for load it again

Thanks for your help

MajorTom
 
Thanks I will consider the static class,
but
I used this technique with creating RecognizerContexts on a TabletApp that
worked well there as well, the RecognizerContext obect is a huge hit , :)
Make one, use it everywhere,

I don't know this, can you send some code example, or some links

Thanks for your help

MajorTom

Mark Woodief said:
Well one thing to consider is this design.

I was writing an application recently that had an incredible amout of lookup
tables, so I needed some sort of dataset that all parts of my app could get
to to implement the combo box's datasource property.

I used a static class that held a series of static DataSets,
this allowed me to get the datasets desired without recreating a new
instance of anything at runtime, :)
Works great, if you would like me to further explain or show you by code
examples let me know, it seems to work well.
I used this technique with creating RecognizerContexts on a TabletApp that
worked well there as well, the RecognizerContext obect is a huge hit , :)
Make one, use it everywhere,

Mark

MajorTom said:
Thanks for your help.

As you say that I just be able to share the dataset normally.
I check for the number of rows at the second form, and found they are
there.

the problem was with my control (combobox) that don't display any rows,
datasource and all others necessary proprieties were set, but for a reason
I
don't understand now, I have to set the datasource again at the load event
of the second form.

now is working ok, but when I set de datasource of the combobox

this.cboCodControl.DataSource = this.ds1inv_master1.inv_master;

I get almost the same performance problem (this is what I want to avoid),
the dataset is very big and it take some seconds processing that line of
code (or some one related)

I want to make a example project, but have to deal with a lot of SQL
tables.

Is the another way for me to get the desired results

Tanks very much

MajorTom


in
message news:eESCEFm#[email protected]...
MajorTom,

I think that you are doing something wrong if you have no rows.
Can
you
show some of the code, or a sample project which shows the problem? You
should just be able to share the data set normally.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hello everybody,

I need help on how to use the same datase in two different form, this
is
the
scenario:
at the first form I load a big dataset (ds1) for short, but I not
want
to
load it again at the second form
at some point I use a second form

Form f = new FormX();
f.ShowDialog();

at the f form I need to use ds1, and I have the same ds1 in the f form

I tried assigning public access for f.ds1
and do like this:

Form f = new FormX();
f.ds1 = this.ds1;
f.ShowDialog();

also I tried passing it at the constructor like this:

Form f = new FormX(ds1);
f.ShowDialog();

all the time the dataset ds1 at the second form have no rows
the only way I get the record is using the merge method this way

Form f = new FormX();
f.ds1.Merge(this.ds1);
f.ShowDialog();

but it take the time for filling the dataset f.ds1 again
the solution that I need is to use the same dataset or at least not
take
the
time for load it again

Thanks for your help

MajorTom
 
Back
Top