Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: how to show report head data from DataTable Post Reply Post New Topic
Author Message
crystaliao
Newbie
Newbie


Joined: 27 Sep 2010
Location: Taiwan
Online Status: Offline
Posts: 18
Quote crystaliao Replybullet Topic: how to show report head data from DataTable
    Posted: 07 Nov 2010 at 7:17pm
I got a DataTable for resource, the column COMPANY_NAME only have NULL or certain company name, two kinds of data.

the company name will put on report header, but it's more than one row in my DataTable, so I have problem how to show the data on header?

any help will be appreciated!
thank you.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 08 Nov 2010 at 7:03am
don't think you can do it.  CR only reads 1 row at a time and reports on it.  If it is a group header, it looks at the first row that starts the group, and the last one for a footer...it won't read multiple rows for a header or a footer.
 
You could create a subreport that will load a shared variable that is the concatenated value you are seeking, or you can modify how you are retrieving the data to concatenate the multi row value into 1 column for the report to display.
 
HTH
IP IP Logged
crystaliao
Newbie
Newbie


Joined: 27 Sep 2010
Location: Taiwan
Online Status: Offline
Posts: 18
Quote crystaliao Replybullet Posted: 08 Nov 2010 at 3:33pm
I got a way to solve my problem from my colleague.

I use a parameter named COMPANY_NAME then run a for loop to get a data I want and then set value to the parameter.

hope it gives help to other people too :)

String company_name = "";
for (int i = 0; i < dtObj.Rows.Count; i++)
               {
                    if (!(dtObj.Rows["COMPANY_NAME"] is DBNull))
                    {
                        company_name = (string) (dtObj.Rows["COMPANY_NAME"]);
                        break;
                    }
               }

oRptDoc.SetParameterValue("COMPANY_NAME", company_name);
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.