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 |
![]() |
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 |
![]() |
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 |
![]() |
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 |
![]() |
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 |
![]() |
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 |
![]() |
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 |
![]() |
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 |
![]() |
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 |
![]() |