469,133 Members | 975 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,133 developers. It's quick & easy.

Missing the benefit of DataSets with Crystal 10 with process reload on Next|Previous button activiation

Good afternoon all,

I guess I am missing the benefit of using datasets with Crystal. For
years I have written wrapper apps that used the Pull method and I let
Crystal do all the sql work. Now I have an issue where the queries run
for 4+ minutes so I don't want Crystal doing repeated legwork.

I was under the impression that once the DataSet is filled and bound to
the report the report (crystalviewer) would not need to re-run the
query - thus speeding up paging and such.

The way I have my code set up now, following the scores of examples,
everytime I hit the Next|Previous button in the CrystalViewer the code
is regenerated and the dataset is filled, and the crystalviewer is
assigned and the report takes the same amount of time to move to the
next page as it did on its initial load. I have confirmed that the
acquiring of information and modifying of sql querries on the fly is
working so I am happy with the dataset process itself but I am
dissappointed in the way it is supposedly implemented.

All of the sample code I have seen states to put the dataset and report
object code at the following:

"After the call to InitializeComponent() in PageInit()"

When I put my code inside PageInit() it is called repeatedly whenever
the Next|Previous button is selected. I've tried installing the code
inside the Page_Load() method but it too is called every time the
Next|Previous button is called.

Am I wrong in my believing that this process of creating a dataset,
filling it, assigning it using SetDataSource() method is unneccessary
and detrimental to performance?

Could someone please steer me in the right direction on this - I
believe it is a matter of placing my code in the proper place or
processing the Next|Previous response differently to avoid rebuilding
the report and re-running the dataset build.

Dave
CODE:

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);

// If we have an error in that the report template name is
// set to "error.rpt" then DON'T try to set parameter or connection
info.
if( this.reportDocument1.FileName.IndexOf("error.rpt") == -1 )
{
if( this.reportDocument1.Subreports.Count > 0 )
setsubreportparaminfo();
setvieweroptions();
}

// set up connection information
string myConnString = "Server="
+ cfgFile.getserver().Trim()
+ ";Trusted_Connection=no" // + cfgFile.getconntype().Trim()
+ ";Database=" + cfgFile.getdatabase().Trim()
+ ";UID=" + HttpContext.Current.Session["UserID"]
+ ";PWD=" + HttpContext.Current.Session["Password"];

SqlConnection sqlConn = new SqlConnection(myConnString);

SqlDataAdapter dataAdapter = new SqlDataAdapter();

dataAdapter.SelectCommand = new SqlCommand(this.buildQuery(),
sqlConn);

DataSet dataSet = new DataSet();

// Connect to, fetch data, and disconnect from database
int rowcount = dataAdapter.Fill (dataSet);

// Use Report Engine object model to pass
// populated dataset to report
this.reportDocument1.SetDataSource (dataSet);

setparaminfo( this.reportDocument1 );
this.CrystalReportViewer1.ReportSource = this.reportDocument1;
}

May 31 '06 #1
3 1607
Try caching your dataset .. then hand back the dataset when it asks for it
again.

your code would then become.

if(!Cache.Contains("my data")) {
Cache["mydata"] = GetMyDataSet();
}
return Cache["mydata"];

This should speed you up immensely.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"dekern" <d_******@hotmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Good afternoon all,

I guess I am missing the benefit of using datasets with Crystal. For
years I have written wrapper apps that used the Pull method and I let
Crystal do all the sql work. Now I have an issue where the queries run
for 4+ minutes so I don't want Crystal doing repeated legwork.

I was under the impression that once the DataSet is filled and bound to
the report the report (crystalviewer) would not need to re-run the
query - thus speeding up paging and such.

The way I have my code set up now, following the scores of examples,
everytime I hit the Next|Previous button in the CrystalViewer the code
is regenerated and the dataset is filled, and the crystalviewer is
assigned and the report takes the same amount of time to move to the
next page as it did on its initial load. I have confirmed that the
acquiring of information and modifying of sql querries on the fly is
working so I am happy with the dataset process itself but I am
dissappointed in the way it is supposedly implemented.

All of the sample code I have seen states to put the dataset and report
object code at the following:

"After the call to InitializeComponent() in PageInit()"

When I put my code inside PageInit() it is called repeatedly whenever
the Next|Previous button is selected. I've tried installing the code
inside the Page_Load() method but it too is called every time the
Next|Previous button is called.

Am I wrong in my believing that this process of creating a dataset,
filling it, assigning it using SetDataSource() method is unneccessary
and detrimental to performance?

Could someone please steer me in the right direction on this - I
believe it is a matter of placing my code in the proper place or
processing the Next|Previous response differently to avoid rebuilding
the report and re-running the dataset build.

Dave
CODE:

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);

// If we have an error in that the report template name is
// set to "error.rpt" then DON'T try to set parameter or connection
info.
if( this.reportDocument1.FileName.IndexOf("error.rpt") == -1 )
{
if( this.reportDocument1.Subreports.Count > 0 )
setsubreportparaminfo();
setvieweroptions();
}

// set up connection information
string myConnString = "Server="
+ cfgFile.getserver().Trim()
+ ";Trusted_Connection=no" // + cfgFile.getconntype().Trim()
+ ";Database=" + cfgFile.getdatabase().Trim()
+ ";UID=" + HttpContext.Current.Session["UserID"]
+ ";PWD=" + HttpContext.Current.Session["Password"];

SqlConnection sqlConn = new SqlConnection(myConnString);

SqlDataAdapter dataAdapter = new SqlDataAdapter();

dataAdapter.SelectCommand = new SqlCommand(this.buildQuery(),
sqlConn);

DataSet dataSet = new DataSet();

// Connect to, fetch data, and disconnect from database
int rowcount = dataAdapter.Fill (dataSet);

// Use Report Engine object model to pass
// populated dataset to report
this.reportDocument1.SetDataSource (dataSet);

setparaminfo( this.reportDocument1 );
this.CrystalReportViewer1.ReportSource = this.reportDocument1;
}

May 31 '06 #2
Thanks for the response Greg.

So just where would I place this code?, as the first line in the
OnInit() method?

Dave
Greg Young wrote:
Try caching your dataset .. then hand back the dataset when it asks for it
again.

your code would then become.

if(!Cache.Contains("my data")) {
Cache["mydata"] = GetMyDataSet();
}
return Cache["mydata"];

This should speed you up immensely.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"dekern" <d_******@hotmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Good afternoon all,

I guess I am missing the benefit of using datasets with Crystal. For
years I have written wrapper apps that used the Pull method and I let
Crystal do all the sql work. Now I have an issue where the queries run
for 4+ minutes so I don't want Crystal doing repeated legwork.

I was under the impression that once the DataSet is filled and bound to
the report the report (crystalviewer) would not need to re-run the
query - thus speeding up paging and such.

The way I have my code set up now, following the scores of examples,
everytime I hit the Next|Previous button in the CrystalViewer the code
is regenerated and the dataset is filled, and the crystalviewer is
assigned and the report takes the same amount of time to move to the
next page as it did on its initial load. I have confirmed that the
acquiring of information and modifying of sql querries on the fly is
working so I am happy with the dataset process itself but I am
dissappointed in the way it is supposedly implemented.

All of the sample code I have seen states to put the dataset and report
object code at the following:

"After the call to InitializeComponent() in PageInit()"

When I put my code inside PageInit() it is called repeatedly whenever
the Next|Previous button is selected. I've tried installing the code
inside the Page_Load() method but it too is called every time the
Next|Previous button is called.

Am I wrong in my believing that this process of creating a dataset,
filling it, assigning it using SetDataSource() method is unneccessary
and detrimental to performance?

Could someone please steer me in the right direction on this - I
believe it is a matter of placing my code in the proper place or
processing the Next|Previous response differently to avoid rebuilding
the report and re-running the dataset build.

Dave
CODE:

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);

// If we have an error in that the report template name is
// set to "error.rpt" then DON'T try to set parameter or connection
info.
if( this.reportDocument1.FileName.IndexOf("error.rpt") == -1 )
{
if( this.reportDocument1.Subreports.Count > 0 )
setsubreportparaminfo();
setvieweroptions();
}

// set up connection information
string myConnString = "Server="
+ cfgFile.getserver().Trim()
+ ";Trusted_Connection=no" // + cfgFile.getconntype().Trim()
+ ";Database=" + cfgFile.getdatabase().Trim()
+ ";UID=" + HttpContext.Current.Session["UserID"]
+ ";PWD=" + HttpContext.Current.Session["Password"];

SqlConnection sqlConn = new SqlConnection(myConnString);

SqlDataAdapter dataAdapter = new SqlDataAdapter();

dataAdapter.SelectCommand = new SqlCommand(this.buildQuery(),
sqlConn);

DataSet dataSet = new DataSet();

// Connect to, fetch data, and disconnect from database
int rowcount = dataAdapter.Fill (dataSet);

// Use Report Engine object model to pass
// populated dataset to report
this.reportDocument1.SetDataSource (dataSet);

setparaminfo( this.reportDocument1 );
this.CrystalReportViewer1.ReportSource = this.reportDocument1;
}


Jun 1 '06 #3
Yes in your oninit method ..

"dekern" <d_******@hotmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
Thanks for the response Greg.

So just where would I place this code?, as the first line in the
OnInit() method?

Dave
Greg Young wrote:
Try caching your dataset .. then hand back the dataset when it asks for
it
again.

your code would then become.

if(!Cache.Contains("my data")) {
Cache["mydata"] = GetMyDataSet();
}
return Cache["mydata"];

This should speed you up immensely.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"dekern" <d_******@hotmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
> Good afternoon all,
>
> I guess I am missing the benefit of using datasets with Crystal. For
> years I have written wrapper apps that used the Pull method and I let
> Crystal do all the sql work. Now I have an issue where the queries run
> for 4+ minutes so I don't want Crystal doing repeated legwork.
>
> I was under the impression that once the DataSet is filled and bound to
> the report the report (crystalviewer) would not need to re-run the
> query - thus speeding up paging and such.
>
> The way I have my code set up now, following the scores of examples,
> everytime I hit the Next|Previous button in the CrystalViewer the code
> is regenerated and the dataset is filled, and the crystalviewer is
> assigned and the report takes the same amount of time to move to the
> next page as it did on its initial load. I have confirmed that the
> acquiring of information and modifying of sql querries on the fly is
> working so I am happy with the dataset process itself but I am
> dissappointed in the way it is supposedly implemented.
>
> All of the sample code I have seen states to put the dataset and report
> object code at the following:
>
> "After the call to InitializeComponent() in PageInit()"
>
> When I put my code inside PageInit() it is called repeatedly whenever
> the Next|Previous button is selected. I've tried installing the code
> inside the Page_Load() method but it too is called every time the
> Next|Previous button is called.
>
> Am I wrong in my believing that this process of creating a dataset,
> filling it, assigning it using SetDataSource() method is unneccessary
> and detrimental to performance?
>
> Could someone please steer me in the right direction on this - I
> believe it is a matter of placing my code in the proper place or
> processing the Next|Previous response differently to avoid rebuilding
> the report and re-running the dataset build.
>
> Dave
>
>
> CODE:
>
> override protected void OnInit(EventArgs e)
> {
> InitializeComponent();
> base.OnInit(e);
>
> // If we have an error in that the report template name is
> // set to "error.rpt" then DON'T try to set parameter or connection
> info.
> if( this.reportDocument1.FileName.IndexOf("error.rpt") == -1 )
> {
> if( this.reportDocument1.Subreports.Count > 0 )
> setsubreportparaminfo();
> setvieweroptions();
> }
>
> // set up connection information
> string myConnString = "Server="
> + cfgFile.getserver().Trim()
> + ";Trusted_Connection=no" // + cfgFile.getconntype().Trim()
> + ";Database=" + cfgFile.getdatabase().Trim()
> + ";UID=" + HttpContext.Current.Session["UserID"]
> + ";PWD=" + HttpContext.Current.Session["Password"];
>
> SqlConnection sqlConn = new SqlConnection(myConnString);
>
> SqlDataAdapter dataAdapter = new SqlDataAdapter();
>
> dataAdapter.SelectCommand = new SqlCommand(this.buildQuery(),
> sqlConn);
>
> DataSet dataSet = new DataSet();
>
> // Connect to, fetch data, and disconnect from database
> int rowcount = dataAdapter.Fill (dataSet);
>
> // Use Report Engine object model to pass
> // populated dataset to report
> this.reportDocument1.SetDataSource (dataSet);
>
> setparaminfo( this.reportDocument1 );
> this.CrystalReportViewer1.ReportSource = this.reportDocument1;
> }
>

Jun 1 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Dr. Indera | last post: by
reply views Thread by cycloneboy | last post: by
6 posts views Thread by Stefan Mueller | last post: by
1 post views Thread by steveberwick | last post: by
8 posts views Thread by GaryDean | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.