locked
Crystal Report: Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)) RRS feed

  • Question

  • User-1565161437 posted

    Hi everyone. I am havng this error when I try to generate my reports. Anyone who knows what to do? Any advice?

    I've already checked my parameter names because that was supposed to be the solution on my problems. But it didn't work.

    Here is myt Stored procedure:

    ALTER PROCEDURE [dbo].[GenerateOrgPlanningReport]
    (
    
    	  @HP VARCHAR(100) = NULL
    	, @FTW VARCHAR(100) = NULL
    	, @LocalSupervisor VARCHAR(100) = NULL
    	, @JobLevel VARCHAR(100) = NULL
    	, @JobType VARCHAR(100) = NULL
    	, @Positions VARCHAR(100) = NULL
    	, @Divisions VARCHAR(100) = NULL
    	, @Gender VARCHAR(100) = NULL
    	, @YrOfUpdateFROM VARCHAR(100) = NULL
    	, @YrOfUpdateTO VARCHAR(100) = NULL
    	, @EmployeeName VARCHAR(100) = NULL
    
    )
    AS BEGIN
    
    SELECT
    	Emp.FirstName + ' ' + Emp.LastName AS EmployeeName,
    	CAST (Cmg.OverallPARating as VARCHAR(50)) AS OverallPARating,
    	Pos.PositionName,
    	Emp.ReportingToName,
    	Emp.DateJoined,
    	YEAR (GETDATE()) - CAST (SUBSTRING(emp.CurrentPositionDate, 4, 4) AS INT)AS IncumbentYearsInCurrentPosition ,
    	YEAR (GETDATE()) - CAST (SUBSTRING(emp.DateJoined, 4, 4) AS INT) AS IncumbentYearsInService,
    	Cmg.MonthlySalary,
    	Cmg.Performance,
    	Cmg.Collaboration,
    	Cmg.Potential,
    	Rep.ReplacementName,
    	Rep.DegOfReadinessID,
    	Rep.ReplacementCompensation,
    	(SELECT TOP (1)YEAR (GETDATE()) - CAST (SUBSTRING(emp.DateJoined, 4, 4) AS INT) FROM Employees Emp WHERE Rep.ReplacementEmployeeID=Emp.EmployeeID) AS ReplacementYrsInService 
    --(SELECT TOP (1) Cmg.MonthlySalary FROM ColorMeGreens Cmg WHERE Cmg.EmployeeID = Rep.ReplacementEmployeeID) AS ReplacementCompensation
    	
    	
    FROM Employees Emp
    
    LEFT JOIN ColorMeGreens Cmg
    ON Cmg.EmployeeID = Emp.EmployeeID
    
    LEFT JOIN Positions Pos
    ON Pos.PositionID = Emp.PositionID
    
    LEFT JOIN Replacements Rep
    ON Rep.EmployeeID = emp.EmployeeID
    
    
    WHERE
    	Cmg.YearOfUpdate BETWEEN @YrOfUpdateFROM AND @YrOfUpdateTO
    	
    	-- AND ((@EmployeeID IS NULL)OR (Emp.EmployeeID = @EmployeeID))
    	 AND ((@FTW IS NULL) OR (Cmg.FTW = @FTW))
    	 AND ((@HP IS NULL) OR (Cmg.HP = @HP))
    	 AND ((@LocalSupervisor IS NULL) OR (Emp.ReportingToName = @LocalSupervisor))
    	 AND ((@JobLevel IS NULL) OR (Emp.JobLevelID = @JobLevel))
    	 AND ((@JobType IS NULL) OR (Emp.JobTypeID = @JobType))
    	 AND ((@Positions IS NULL) OR (Emp.PositionID = @Positions))
    	 AND  ((@Divisions IS NULL) OR (Emp.DivisionID = @Divisions))
    	 AND ((@Gender IS NULL) OR (Emp.Gender = @Gender))
    	 AND ((@EmployeeName IS NULL) OR (Emp.FirstName + ' ' + Emp.LastName = @EmployeeName))
    
    ORDER BY Emp.EmployeeID
    
    			
    END


    This my code that instantiates the report:


      OrganizationalPlanningReport rpt_OSW1 = new OrganizationalPlanningReport();
    
                rpt_OSW1.SetParameterValue("@HP", HP);
                rpt_OSW1.SetParameterValue("@FTW", FTW);
                rpt_OSW1.SetParameterValue("@LocalSupervisor", LocalSupervisor);
                rpt_OSW1.SetParameterValue("@JobLevel", JobLevel);
                rpt_OSW1.SetParameterValue("@JobType", JobType);
                rpt_OSW1.SetParameterValue("@Positions", Positions);
                rpt_OSW1.SetParameterValue("@Divisions", Divisions);
                rpt_OSW1.SetParameterValue("@Gender", Gender);
                rpt_OSW1.SetParameterValue("@YrOfUpdateFROM", FiscalYrFROM);
                rpt_OSW1.SetParameterValue("@YrOfUpdateFROM", FiscalYrTO);
                rpt_OSW1.SetParameterValue("@EmployeeName", EmployeeName);
                
    
                CrystalReportViewer1.ReportSource = rpt_OSW1;


    Thank you in advance.
    PS. I've also tried replacing my @parameter1 with indexes like 0, 1, ...




    Thursday, September 20, 2012 5:40 AM

All replies

  • User-578610739 posted

    Hi,

    are you check the same parameter value with crystal report. (open report and f5 ,give parameter value). The same result comes, which you want.

    if yes , then save the report.

    This check with hardcore value.

    rpt_OSW1.SetParameterValue("@HP", 2); //rather than HP
    rpt_OSW1.SetParameterValue("@FTW", 5) ; //rather than FTW

    see this also.

    http://social.msdn.microsoft.com/Forums/hi-IN/vscrystalreports/thread/03b40d89-ed52-4dce-bdfc-50126e315365

    http://www.codeproject.com/Questions/226633/Crystal-Report-Invalid-index-Exception-from-HRESUL

    http://www.codeproject.com/Questions/251302/Invalid-index-Exception-from-HRESULT-0x8002000B-DI

    http://forum.katarincic.com/default.aspx?g=posts&t=510

    Thursday, September 20, 2012 12:24 PM
  • User-1565161437 posted

    Thank you Ajay2707! :)

    But this is how I solved my problem, I updated my stored procedure in SQL Server but didn't updated it in the Visual Studio. What I did was to verify the datasource location and the error didn't showed up. :)

    But I've got a new problem, the crystal report generates on runtime but it doesn't show anything. I checked my stored procedure by executing it on the database, it works well. I also tried executing it using the main report preview, it works too.

    Problem is, there really is no data showing when I run the project and generate the report.

    Anyone who have experienced this? Thank you guys.

    Thursday, September 20, 2012 11:19 PM