I'm new to Crystal Reports and trying to maintain someone else's code -- so bear with me. I have a crystal report that is tied to a DataSet with 2 related DataTables.
I'm grouping by JurorProfile.JurorPK
. In my Group Header, I display information from the JurorProfile DataTable.
In the report detail, I have RowNumber, JurorQuestionAnswers.Question
and JurorQuestionAnswers.Answer
.
In my c# code, I'm populating the data like this:
public void SetDataSource(AdoProvider provider, int sessionPK, int jurorPK)
{
string commandText;
AdoQuery query;
commandText = $@"select j.* from Juror j
where j.JurorPK in (select JurorFK from SessionJurorLink where SessionFK = @sessionId)
{(jurorPK > 0 ? " and jurorPK = @jurorId" ? "")}
";
query = provider.CreateQuery(commandText, null
, provider.CreateParameter("sessionId", DbType.Int32)
, provider.CreateParameter("jurorId", DbType.Int32)
);
AdoReader jReader = query.ExecuteReader(sessionPK, jurorPK);
report.Database.Tables["JurorProfile"]
.SetDataSource((IDataReader)jReader.DataReader);
commandText = $@"select ... from JurorAnswers ...
where sessionFK = @sessionId
{(jurorPK > 0 ? " and jurorFK = @jurorId " : "")}
order by JurorFK, Rank, ParentFK, QuestionPK
";
query = provider.CreateQuery(commandText, null
, provider.CreateParameter("sessionId", DbType.Int32)
, provider.CreateParameter("jurorId", DbType.Int32)
);
AdoReader qaReader = query.ExecuteReader(sessionPK, jurorPK);
report.Database.Tables["JurorQuestionAnswers"]
.SetDataSource((IDataReader)qaReader.DataReader);
}
However, when my report runs, the Group Heading displays and I get a record number printed for each question but the Question and Answer are not displayed.
It would appear, that Crystal Reports is not mapping the data results from my second query to the DataTable.
What's even weirder is that JurorQuestionAnswers
DataTable currently has a redundant Lastname and Firstname field. If I include those fields in the detail area (JurorQuestionAnswers.Lastname
, JurorQuestionAnswers.Firstname
), they actually show up -- the data was properly mapped.
What am I doing wrong?
Update - Image of Links Tab