Crystal Reports on the web

Looking at the huge number of links, my code snippets and samples that I've accumulated during my journey with Crystal Reports and Report Server (RAS), I've realized that something should be done with all that. So, for all who are struggling with similar problems I've faced while pursuing that elusive goal of putting Crystal Reports on the web, I will put as much information here as I can ...

Friday, June 25, 2004

Create Field object in RAS

To add field onto report, create a field object first ..


private Field ConvertFieldStringToFieldClass(string fieldString)
{
// get the period index
char period = '.';
int periodIndex = fieldString.IndexOf(period);
// parse out table and field name
string tableName = fieldString.Substring(1, periodIndex-1);
string fieldName = fieldString.Substring(periodIndex+1, fieldString.Length-(periodIndex+2));
Tables tables = _reportClientDocument.DatabaseController.Database.Tables;
int tableIndex = tables.FindByAlias(tableName);
CrystalDecisions.ReportAppServer.DataDefModel.Table table =
(CrystalDecisions.ReportAppServer.DataDefModel.Table)tables[tableIndex];

Fields fields = table.DataFields;
int fieldIndex = fields.Find(fieldName, CrFieldDisplayNameTypeEnum.crFieldDisplayNameName,
CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishUS);
Field field = (Field)fields[fieldIndex];
return field;
}


0 Comments:

Post a Comment

<< Home