Print Page | Close Window

Pass paramater from C#.net application to Crystal

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Writing Code
Forum Discription: .NET 2003 programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=5831
Printed Date: 19 May 2024 at 7:11am


Topic: Pass paramater from C#.net application to Crystal
Posted By: talljames
Subject: Pass paramater from C#.net application to Crystal
Date 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!



Replies:
Posted By: hilfy
Date 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


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: talljames
Date Posted: 26 Mar 2009 at 10:54pm
Hi Hilfy,
 
I started a post at https://www.sdn.sap.com/irj/scn/forum?forumID=313&start=0 - https://www.sdn.sap.com/irj/scn/forum?forumID=313&start=0
 
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 



Print Page | Close Window