Problem with passing parameters from VB.Net to Crystal reports

I have been using Crystal reports XI with my ASP.NET website for quite some time now. I am trying to add a new crystal report to my ASP.NET website. I was able to design and create the website fine. But when I try to run the report, at run time I get 'System.Runtime.InteropServices.COMException: Invalid index' error. This happens when I try to set the paramater value for my stored procedure. I am pretty sure that I have spelled the parameter name correctly.

I notice a couple of things here. The ParameterType for this new report says 'StoredProcedureParameter' where as for all other reports it is 'ReportParameter'. I tried changing the parameter type but could not.  I am using VS 2003, Crystal Reports XI, and SQL Server 2005

I am wondering I am doing something wrong with the way I create the crystal report. Any help would be greatly appreciated.

 

Here is the code

arParams(0) = New SqlParameter("@BeginDate", Session("BEGINDATE"))
arParams(1) = New SqlParameter("@EndDate", Session("ENDDATE"))
arParams(2) = New SqlParameter("@IDSTATUS", Session("STATUSID"))
arParams(3) = New SqlParameter("@COMPANY", Session("COMPANY")
 
strReportPath = Server.MapPath("../webleads/Reports/" & Request.Cookies("LOGIN_CLIENTID").Value & "/" & strReportType & ".rpt")
 
myDs = MyLead.GetRecordWithParamDataset("spGetFUAReport", ConfigurationSettings.AppSettings(Request.Cookies("LOGIN_CLIENTID").Value), arParams)
 
ReportDoc.Load(strReportPath)
ReportDoc.SetDataSource(myDs)
 
Dim BeginDate As New ParameterField
Dim EndDate As New ParameterField
 
Dim BeginDateVal1 As New ParameterDiscreteValue
Dim EndDateVal2 As New ParameterDiscreteValue
 
BeginDate.ParameterFieldName = "BeginDate"
EndDate.ParameterFieldName = "EndDate"
 
BeginDateVal1.Value = Session("BEGINDATE")
EndDateVal2.Value = Session("ENDDATE")
 
ReportDoc.SetParameterValue(BeginDate.ParameterFieldName, BeginDateVal1.Value) 'This is where I get the erroe
ReportDoc.SetParameterValue(EndDate.ParameterFieldName, EndDateVal2.Value)

 

 

 

0
unbreakable
7/23/2008 6:45:11 AM
asp.net.crystal-reports 7043 articles. 0 followers. Follow

8 Replies
5654 Views

Similar Articles

[PageSpeed] 51

 Hi,

Can you try this....

 =================================================================               

ReportDoc.SetParameterValue(0, BeginDateVal1.Value)               
ReportDoc.SetParameterValue(1, EndDateVal2.Value) 

=================================================================== 

above code is work for my sln. 


** Don't forget to mark as "ANSWER" if it's help for you **

Profanity is the one language all programmers know best.

Thanks.
Md. Nazmul Ahsan
0
nazmul_ahsan
7/23/2008 7:02:50 AM

Hi Nazmul,

I tried that too and it won't work. When I debugged my VB.NET code, I found that the ReportDoc.ParameterType being set to 'StoredProcedureParameter'. But for all the working reports (that were created some time back), it is set as 'ReportParameter'. I am wondering if I did something wrong with the way I created the new report that is causing this issue. Just to let you know, I use VS2003 for my ASP.NET project, Crystal Reports XI and SQL Server 2005 as the database.

Thanks for your help and any further help would be greatly appreciated. 

 

0
unbreakable
7/23/2008 11:02:40 PM

Hi

There are two types of parameters in CR. Parameters which are Specific to  stored procedures are storedprocedure parameter and the parameters specific to report are report parameters.

Did u change the datatype of the storeprocedure parameter by anytime.. just set the datasource of the report again. and verify database once. Check the datatype of the parameter which is giving problem in the storedprocedure as well as in the report.


VMSSanthosh
When you ask a question, remember to click "mark as answered" when you get a reply which answers your question; this ensures the right forum member gets credit below for being helpful (and makes search more relevant too).
0
vmssanthosh
7/24/2008 5:11:12 AM

 Hi ,

It's seem everything is right in your code. I think you was missing something during create crystal report. Delete that one and create new one form beginning. Let me know if you solve it.


** Don't forget to mark as "ANSWER" if it's help for you **

Profanity is the one language all programmers know best.

Thanks.
Md. Nazmul Ahsan
0
nazmul_ahsan
7/24/2008 5:16:45 AM

Recreate the crystal reports and check it.

Just go through the detailed vb.net crystal reports tutorial.

http://vb.net-informations.com/crystal-report/vb.net_crystal_reports_tutorials.htm

lev

0
boltonss
7/24/2008 8:46:35 AM

I didn't change the datatype of the stored procedure parameter. There are four parameters in my stored procedure. Two are of datatype - 'Datetime', one of type 'bigint' and the last one of type 'varchar'.

0
unbreakable
7/24/2008 2:57:47 PM

In report setdatasource once again and refresh the report once and check the same problem is occuring or not


VMSSanthosh
When you ask a question, remember to click "mark as answered" when you get a reply which answers your question; this ensures the right forum member gets credit below for being helpful (and makes search more relevant too).
0
vmssanthosh
7/25/2008 3:23:43 AM

 I tried that too. But still couldn't get rid of the problem.

Here is what I found out. After I add the stored procedure to the crystal report, the parameter fields in the crystal report show the parameters from the stored procedure. These are the parameters that are not recognized by the VB.NET code. But when I right click on the 'Parameter Fields' in Crystal reports and add the parameters manually, then VB.NET could see that code. But the problem with this is, the values I set in VB.NET are not getting passed to the database. 

 

Is there a way to tell Crystal report not to 'automatically' add parameters when attaching a stored procedure?

0
unbreakable
7/25/2008 7:05:44 AM
Reply:

Similar Artilces:

Converting Crystal Reports 9 report to Crystal Reports .NET report
I have a web page that is supposed to display a crystal report.  The report is fully written and functional in crystal 9 (non-.Net)  .  Is there a way to convert my .rpt so that I can just include it in the new web site? why you don't try to compile project with .net and include your report. then if crystal report is power tool will suggests you with conversation tool    My blog is here.Please remember to 'Mark as Answer' if this post answered your question! Wow it really was that easy!  I just added the old crystal report into my .NET proj...

crystal reports .net -> crystal reports .net 2003
recently converted a project from .net to .net 2003. The 2 crystal reports I had in the project do not load when executing the application. The project itself within 2003 will allow me to multiplat the crystal reports, however when it comes to execution time I get the error: Invalid Data Source. If this isn't the right forum please point me to the right one as this is really the only website I know of with a large reader base. >to multiplat the crystal reports To what the crystal reports? Do you have the same database connections established and verified in your 2003 s...

upgrading vb.net to vb.net 2003 crystal report viewer problem.
I have a vb.net web. app that has several pages each with a different crystal report on it. It works perfectly under vb.net. I've since installed vb.net 2003. After I open the solution in 2003 & it does its upgrade, all of the crystal report viewer controls are corrupted. If I try to run it as is I get the following error: "The base class includes the field 'myname' but its type (CrystalDecisions.Web.CrystalReportViewer) is not compatible with the type of control(CrystalDecisions.Web.CrystalReportViewer). So I tried deleting the control and adding back on. & when I ru...

How to pass parameter in crystal report using dataset in vb.net
 dear friends              i am new to crystal report. so i need the detail explanation on crystal report in vb.net i want to create crystal report using dataset,i want to pass parameter value in crystal report or dataset.regards Samuel chandradoss John  Thanks and regardsSamuel Chandradoss John you can refer here http://forums.asp.net/p/1359067/2825312.aspx#2825312   and also http://www.beansoftware.com/ASP.NET-Tutorials/Using-Crystal-Reports.aspxMAKMark as Answer if this reply helps youMVP ASP/ASP.NetASP.Net Hosting : Host DepotM...

integration of Crystal Report with .NET ; crystal report viewer not displaying in Toolbox
Hi I m new to Visual Web Developer 2005 Express Edition. I want to integrate Crystal Report with .NET. In my Toolbox , Crystal Report Viewer is not displaying. How to make it possible? + How to call my report from asp.net 2.0. Need source code plz.*Share Knowledge Every TIME Crystal Reports for .NET does not come with VWD Express.  It only comes with VS 2005 Professional (I'm not sure about the Standard edition).If you have Crystal Reports 10 or XI, you can installed the .NET libraries for Crystal and then use them within VWD Express, noting that you have to build your reports ...

VS .net 2005 Crystal reports ok to run on Crystal Reports XI?
I am getting mixed messages from the asp.net website hosting providers - some say they do not support Crystal Reports due to a $25,000 per cpu licensing fee, others say all I need to do is install Crystal Reports XI (about $500) on a dedicated server and it will run fine. Will Reports developed with the embeded Crystal Reports in VS 2005 run in a Crystal Reports XI environment? Thanks....

Cassini, VS.Net and Crystal Reports
Hi,I am working with Win XP home, Cassini and VS.Net.I would like to play with some Crystal Reports.I create the report in VS as CrystalReport1.I put a CrystalReportViewer on my web form. It does not get recognized as a defined object type but there are no build errors.When I run the app I get an error: Type 'CrystalReport1' is not defined.I have googled on this and see several things people have suggested/tried to correct this. Most I have already tried or the suggestions are not very clear to me. Then I came across a msg that instructed me to set up virtual directories for IIS for CrystalR...

Errors with all my reports after upgrade from Bundeled Crystal.NET (VS2003) to Crystal XI Developer for .NET
All my Crystal reports were developed using the bundled Crystal in VS 2003.  I just installed the Crystal XI for .NET Developer version that we purchased and now I get an error when running my reports.  (I am running them in debug mode on my development machine). I have tested it on several different reports.  I did not change the code, this worked fine in the previous version. First I reference my report (AccountList is the AccountList.rpt report that is in my project): Dim myReport As New AccountList Then I start rolling through the report's tables to update the log...

Can somebody help
I Seem to be going nuts ! I know it has to be simple but I am missing the link. I haven't used crystal reports with asp.net before. So pardom me if my problem sounds silly. My requirement is very simple actually. I am using asp.net 1.1 with vb.net in vs.net 2003 with the inbuilt crystal reports control. I have to connect to a sql server 2000 database to extract rows from a stored procedure which accepts a parameter and the report has to be in Mail label format. I referred various books and web sites and according to that , added a crystal reports file to the project and selected the store...

Crystal report Print Porgramatically and pass Perameter in vb.net(Desktop Application)
helloIn my project i want to print report Programatically without privew of Report.i con't able to print my reprot,when report is print that time just only header is printig here i m add my code please suggest me what is wrong herepage load(){ crReportDocument = New ReportDocument()//find printer  Dim printDocument As New System.Drawing.Printing.PrintDocument()            crReportDocument.PrintOptions.PrinterName = printDocument.PrinterSettings.PrinterName  Path = Application.StartupPath    &nb...

Crystal Reports in VB.NET
I am not new to vb.net or Crystal but I am new to incorporating the two.   What do I need to add reference to inorder to show an already created Crystal Report?  And what is the form control for viewing Crystal Reports?...

Crystal Report.NET and nested sub reports
I have a report where i need to have several nested subreports... A parent may have childs and childs may have other childs and so on... CrystalReport.NET and VS2005 seems to support one level of subreport (a report could have a nested subreport but this nested subreport can't have another nested subreport). I really need to handle multiple levels of nested subreports in order to complete my report. What is the solution ???   Thanks   Eviral     I'm not positive if this works but its worth a shot.  Create the subreports as se...

Reporting (Crystal Reports vs. Custom .NET)
Ok, so I have to confess, I have never tried Crystal Reports. I just recently started working for a marketing company now and reporting is VERY important to them.  I am currently migrating a lot of the applications they use from VB5 and VB6 to web based .NET 3.5 apps.   The whole company is running off ACCESS databases if you can believe that.  They sometimes have up to a few hundred agents taking sales on incoming calls and chat sessions and they are all getting streamed to FLAT file records (completely un-normalized database).  I am in the process of developing a c...

Bind crystal reports / sql reports to ADO.NET
Hi,  I'm a beginner trying to find out if it's possible to directly connect an sql report/crystal report to an ADO.NET data set?   It all depends on what version of Visual studio you are using. Here are the steps for VS2005 In VS2005 you need to do the following: 1) Right click on your solution and select add, New Item. 2) Add a dataset and create your queries in the dataset. Make sure you save this dataset or it will not show up later. 3) Add your reportviewer 4) Right click on your solution and select add new Item Again and then add a crystal report 5) In the cr...

Web resources about - Problem with passing parameters from VB.Net to Crystal reports - asp.net.crystal-reports

Parameter - Wikipedia, the free encyclopedia
A parameter (from the Ancient Greek παρά , "para", meaning "beside, subsidiary" and μέτρον , "metron", meaning "measure"), in its common meaning, ...

fb_source Parameter - Facebook-Entwickler
This document lists the complete list of values for the fb_source parameter that is returned with th...

Google / Firefox Parameter - Flickr - Photo Sharing!
HS what? www.seroundtable.com/archives/017105.html

Cat 8: TIA performance standards committee chairman previews parameters of forthcoming twisted-pair cable ...
Category 8, the next-generation twisted-pair cabling specification, is still in development, but the outlook looks quite positive that it will ...

Philippine president asks for 'parameters' of Mayon Volcano tours
Philippine president asks for 'parameters' of Mayon Volcano tours People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, Apr, May, ...

Alternatives to boolean parameters
... ) { PrintLine ( item . Name ); if ( printDetails ) { PrintLine ( item . Description ); } } } Aha! Now can see that the boolean parameter ...

Exporting Error (Error in Parameter...: Apple Support Communities
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability ...

Apple tech monitors device aging, adjusts operating parameters to ensure optimal performance
... describing a method of monitoring the aging of a device's electronics, comparing the data with a global average and modifying operating parameters ...

Is it poor programming practice to pass parameters as objects?
... a free, community-powered network of 100+ Q&A sites . Risser asked: So, we've got a guy who likes to write methods that take Objects as parameters, ...

Parameter Short Film Competition sponsored by Grolsch
Grolsch presents Parameter The A.V. Club Short Film Competition Please Enter Your Date of Birth Ineligible entry Enter For people over the age ...

Resources last updated: 1/20/2016 9:06:57 AM