|
Hello,
I am a newbie in Crystal Reports. I need to sort the report based on the column that the user sets in the windows form. How do I do it?
I've been googling with virtually no help
Thanks in advance.
Regards,
Zishan
|
|
|
|
|
I don't think you can tell the report to sort from your code. One solution is to build many report, one for each column which the user can choose.
<italic>Work hard, Work effectively.
|
|
|
|
|
Thanks for replying. There should be a way. I got a sample code, Its in VB, I tried it in C# but for some reason.. it doesn't work for me. Here's the code :
Dim crSortDirection As SortDirection
Dim crDatabaseFieldDefinition As DatabaseFieldDefinition
Dim crSortField As SortField
Dim iSortItem As Integer = 0
crDatabaseFieldDefinition = crReportDocument.Database.Tables(0).Fields(6)
crSortField = crReportDocument.DataDefinition.SortFields(6)
crSortField.Field = crDatabaseFieldDefinition
'crSortField.SortDirection = SortDirection.AscendingOrder
crSortField.SortDirection = SortDirection.DescendingOrder
There is no explanation available for the code. No matter what SortField I pass, it keeps throughing CrystalDecisions.CrystalReports.Engine.InvalidArgumentException -> Invalid SortNumber.
Can you explain now?
Zishan
|
|
|
|
|
Ar you sure your C# syntax is correct? In case you are passing a groupfield instead of a databaseField, use the base class:
FieldDef = new FieldDefinition ();
FieldDef = Report.Database.Tables [0].Fields [6];
Report.DataDefinition.SortFields [0].Field = FieldDef;
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
Same problem Can I make a stored procedure and pass the "order by" parameter? I think that's going to solve the problem. I am using Crystal Reports that comes with the VS.net 2003. How can I call a stored procedure and pass the parameter?
Many thanks.
Zishan
|
|
|
|
|
I have used crystal in a few of my apps and the way I handle sorting is by sorting the datasource ( i use a dataset as the source ). So based on a selected column by the user, sort the dataset into the desired order or load the data into the dataset by specifying the SORT keyword in the sql statement when retrieving the data.
Hope this helps.
Craigo
|
|
|
|
|
Craigo, I tried what you told me.. it is picking up all the records in the table without any order. I commented the t.SetDataSource line.. still the same result. I am not sure if this is the right way to define Data Source. Here is my code :
Report2 t = new Report2();
string Query = "Select * from Orders order by ordertype asc";
SqlComm.CommandText = Query;
SqlDataAdapter da = new SqlDataAdapter(SqlComm);
DataSet data = new DataSet();
da.Fill(data);
t.SetDataSource(data);
this.Viewer.ReportSource = t;
Zishan
|
|
|
|
|
2 Things you can try.
1) change the code where you set the datasource to :
t.SetDataSource(data.Tables[0])
2) Add the line: t.EnableSaveDataWithReport=false;
after you have set the datasource
Let me know how you get on
Craigo
|
|
|
|
|
Hey Craig, thanks a lot man.. you saved my life.. although I don't have t.EnableSaveDataWithReport property but the problem is now solved.. Thanks for your help!
Zishan
|
|
|
|
|
hi to all,
i have developped a web service in c# .net on my local machine (localhost).
then i create a c# win application and i added the web reference (on the local host) to cosume this web service and everything works fine.
how can i put the web service on the server (windows 2000 server). and then where can i add the web reference to my c# win application to cosume it.
do i have to install the .net frame work on the server and then copy my web service project on that server ?
note that all the client terminal does not have an IIS
best regards and thanks in advance
fady
|
|
|
|
|
You have to install iis to your server and deploy your service there.
Then you can add a web reference to the server
Eg: http://ipAddress/......
Regards,
charith
|
|
|
|
|
thanks to your reply charith,
do i have to install .net framework on the server or not ?
best regards,
fady
|
|
|
|
|
Hi fady
I think you have to install the framework.Not sure!
Sometimes it might work without the framework..
regards;
charith.
|
|
|
|
|
thanks charith,
i will try with the .net framework
thanks to your reply again
fady
|
|
|
|
|
charith@ramedian.com wrote:
Sometimes it might work without the framework..
Nothing .NET works without the framework....ever (I cant see how you could say "sometimes it might work" )
|
|
|
|
|
Thanks
|
|
|
|
|
I have written a webservice using ASP. There is a class named ReferenceDetails. I can add the webservice to my client side
and create a object of type ReferenceDetails.No problem!
private int _intRefID;
private int _intPatientID;
private int _intDoctorID;
private DateTime _beginDateTime;// = new DateTime();
public ReferenceDetails()
{
this._beginDateTime = new DateTime();
}
I have written another class at the backend containing ReferenceDetails object;
private ReferenceDetails _refDetails = new ReferenceDetails();
public RemindDetailsWrapper()
{
}
The problem is when i am creating a RemindDetailsWrapper() object at the client side it doesn't contain ReferenceDetails object.
Thanks :
|
|
|
|
|
Salam,
I have a rectangle(whose width, height etc is in millimeters) and a string. I want to know how much(no. of characters) of the string can be drawn in that rectangle keeping in view word breaks, line spacing etc. I have used MeasureString but the characters given by it are greater than actual that can be drawn in that rectangle.
|
|
|
|
|
How have you used MeasureString? It does not return a number of characters but the size needed to draw the string.
Have you specified the same font and size for MeasureString as you use when you draw the text?
---
b { font-weight: normal; }
|
|
|
|
|
Hi
If I have a class Person eg:
Class Person
{
private int identity;
public int Identity
{
get
return this.identity;
set
this.identity = value;
}
How can I get the value of identity (for example) using Reflection if I use the following type of code.
Person person = new Person();
this.DoSomething(person);
public void DoSomething(object obj)
{
//int identity = ???????;
Console.Writeline("Identity = " + identity);
}
}
I tried using the Type.PropertyInfo and GetValue, but the help documentation is not that clear and I did not manage.
Can anybody help me with an example perhaps.
Thanks.
Kobus
|
|
|
|
|
public static int GetIdentity(Person person){
Type type = person.GetType()
BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Instance
FieldInfo field = type.GetField("identity", flags)
Object value = field.GetValue(person)
return (int)value
}
I'm a wreck at C#, but i hope this helps!
|
|
|
|
|
For anyone working their way through the Que Certification for exam 316 there is an error in exercise 2.18. For the code to work correctly you will need to add a using System.IO directive otherwise you will not be able to compile the code.
Most people are willing to pay more to be amused than to be educated--Robert C. Savage, Life Lessons
Toasty0.com
Ladder League (beta)
My Grandkids
|
|
|
|
|
How do I develop my C# project into a stand alone software that can run on any computer?
|
|
|
|
|
fire up vs and select new visual c# project then choose the "Windows Application" Template. That will create your stand alone software.
|
|
|
|
|
But I face problems when i try to run the application in computers that do not have visual studio .net.
|
|
|
|