Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All

I got an exception: Invalid index. Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)

and the code is:

C#
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@"D:\ProjectwithJavascript112\ProjectwithJavascript112\SchoolMgtSys\SchoolMgtSys\SchoolMgtSys\Admin\Reports\CrystalReport1.rpt");
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = "Cultural";
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["cs_type"]; //Here Exception comes
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Add(crParameterDiscreteValue);
                    crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
crConnectionInfo.ServerName = "Rajni";
crConnectionInfo.IntegratedSecurity = false;
crConnectionInfo.DatabaseName = "SSS_smis";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "sss";
CrTables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
    crtableLogoninfo = CrTable.LogOnInfo;
    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
    CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
viewr_for_type.ReportSource = cryRpt;
}
Posted
Updated 22-Jul-10 21:41pm
v3
Comments
Sandeep Mewara 23-Jul-10 4:48am    
Would be nice if you add the line number that gives this error!

1 solution

Just by looking at it, does
C++
crParameterFieldDefinitions["cs_type"];

allows 'string' key to get indexed values? Might be only integers can be used. Please check. VS intellisense itself can tell you about it.

UPDATE:
Based on the class definition and the properties, it does not look like that you are accessing it correctly. Might be you want to use 'Item' property.

look here:
ParameterFieldDefinitions Class[^]
ParameterFieldDefinitions Properties[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900