471,337 Members | 1,194 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Sorting Crystal Reports programmatically

Hello,

I'm still learning Crystal reports, and now I need to sort report
programmatically. I've found a good article about it:
http://blogs.ittoolbox.com/c/coding/...atically-16201.
This is how it described there:

ReportDocument objReport = new ReportDocument();
objReport.Load("Your report path");
FieldDefinition FieldDef;
FieldDef = objReport .Database.Tables[0].Fields[sortField];
objReport.DataDefinition.SortFields[0].Field = FieldDef;
objReport.DataDefinition.SortFields[0].SortDirection =
CrystalDecisions.Shared.SortDirection.DescendingOr der;

When I try to do this, I'm getting an error on this line:

objReport.DataDefinition.SortFields[0].Field = FieldDef;

Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))

This error is also described in this article:

"This is because you didn't define any sort field in your crytal report...
so if you try to add a FieldDef to the SortFields at a specified index and
that index doesn't exist then you will get the error..."

But there is no explanation how to define the sort fields in the report.
I've searched the Google and found several posts about the same issue, but
also no explanation.

So how can I define the sort fields for the report so I could sort
programmatically?

I would appreciate your help.

Thank you,

Peter
Jun 27 '08 #1
0 1830

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Wilson Ricardo Passos Oliveira | last post: by
3 posts views Thread by Gheaci Maschl | last post: by
7 posts views Thread by p | last post: by
3 posts views Thread by Andrew | last post: by
reply views Thread by rosydwin | last post: by

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.