Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: Pass paramater from C#.net application to Crystal Post Reply Post New Topic
Author Message
talljames
Newbie
Newbie
Avatar

Joined: 19 Mar 2009
Location: Australia
Online Status: Offline
Posts: 3
Quote talljames Replybullet Topic: Pass paramater from C#.net application to Crystal
    Posted: 19 Mar 2009 at 10:12pm
Hi all, I am running Visual Studio.net 2003 with Crystal Reports 9. I am trying to pass a parameter to the SQL command as follows:

I understand that the C#.net command SetParameterValue(string, object) has some issues with service pack 1.

I am trying to pass a parameter into my Crystal Report SQL Command using the following:

In my AuctPurchaseList.cs file I have:

private void crystalReportViewer1_Load(object sender, System.EventArgs e)
{
AuctionPurchase auctReport = new AuctionPurchase();
auctReport.SetParameterValue("SaleIDParam1", "35");
//auctReport.SetParameterValue("SaleIDParam2", "46");
crystalReportViewer1.ReportSource = auctReport;
}

In my SQL Command I have:

SELECT TempSales.SaleID, TempSales.CustomerID, TempSales.SupplyID, TempSales.UnitsLots, TempSales.Lots, TempSales.Price FROM SeaMarket.TempSales WHERE TempSales.SaleID >= '{?SaleIDParam1}' ORDER BY TempSales.CustomerID, TempSales.SaleID

In my AuctionPurchase.rpt file (created by Crystal Reports design within Visual Studio.net 2003) I have a Parameter Field called SaleIDParam1 set as a string, with a default value of 35 (also with Allow multiple values checked and Descrete value checked). note:TempSales.SaleID is an integer in the database.

The report is printing ok but it is showing all values and not just those with a saleID of 35 and above. Which seems to suggest that the parameter passing is not working.

I know this is a dated package, but if there is someone who has been around in this space for some time.

with regards

Additional note:
 
Well, the good folks at Crystal Reports provided the link for service pack 2 and so I downloaded it and installed it. Unfortunately, it did not fix my issue. I would have thought that this was quite a basic procedure for VS 2003.net, but after doing much searching on the web there doesn't seem to be a lot around on this problem. The available use of various methods described at many sites is of course dependent on the available class libraries, which is dependent on the versions of CR, etc.

Maybe, I am looking at this all wrong but I thought the SQL command parameter passing could be achieved quite simply. I have seen it at postings on later versions of Crystal Reports.

I also have Crystal Reports XI R2 professional installed on my machine. I thought that maybe I could use that to generate the report and include the report in Visual Studio.net 2003 for build, but I yet to proove if this is possible, as VS 2003.net still uses .net Framework 1.1.

As there are plenty of legacy apps out there I am sure this would be an issue that could help many.

Hope someone (even a Crystal Reports expert) out there might have a suggestion?

cheers!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 26 Mar 2009 at 1:34pm

I see a couple of things that may be contributing the issue.

1.  If your field is an integer, then you need to pass an integer to it, not a string.
 
2  TempSales.SaleID >= '{?SaleIDParam1}' - This will give you all SaleID's that are equal to or greater than your parameter.  If you want just the Sale ID in the parameter, you need to change '>=' to '='.
 
Also, I believe that if you install CR XI after you install VS 2003, that it will register with VS 2003 - I'm pretty sure that it has .NET 1.1 assemblies.  You don't have to uninstall and reinstall Crystal - I think a "repair" install will take care of registering it all with VS.
 
-Dell
IP IP Logged
talljames
Newbie
Newbie
Avatar

Joined: 19 Mar 2009
Location: Australia
Online Status: Offline
Posts: 3
Quote talljames Replybullet Posted: 26 Mar 2009 at 10:54pm
Hi Hilfy,
 
 
Unfortunately, CR only passes a string or number. I tried a number, but that didn't work.
 
I am waiting on CR dev XI and will try again then.
 
regards 
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.