CR에 경험이있는 사람들에게이 질문이 표시됩니다.크리스탈 보고서 및 연결 문제
Crystal 보고서에 대한 연결 설정에 문제가 있습니다. 고객으로부터 보고서를 받았습니다. 데이터베이스의 구조는 내 서버에서 동일합니다. 그러나 서버와 db의 이름은 다릅니다. 그는 보고서 작성을 위해 "명령"을 사용하고 있습니다 (데이터베이스 필드 - 데이터베이스 전문가의 명령 추가). 이 명령에는 데이터를 반환하는 함수가 있습니다. 내 컴퓨터에서이 보고서를 실행하려고하면 TestConnectivity()를 실행하려고 할 때 문제가 발생합니다.이 메서드는 false를 반환합니다. 디버그를 시도하고 ApplyLogOnInfo() 내부 객체 RasTable에 이전 ConnectionInfo가있는 것을 발견 한 후 발견했습니다.
나는 설정된 연결에 다음 코드를 사용하고 있습니다 :
private void ApplyConnection(ReportDocument report, ConnectionInfo connectionInfo)
{
ApplyLogOnInfo(report, connectionInfo);
ApplyLogOnInfoForSubreports(report, connectionInfo);
}
private void ApplyLogOnInfo(ReportDocument reportDocument, ConnectionInfo connectionInfo)
{
foreach (Table table in reportDocument.Database.Tables)
{
table.LogOnInfo.ConnectionInfo.AllowCustomConnection = true;
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
_log.InfoFormat("Table connection state: TableName = {0}, IsConnect = {1}", table.Name, table.TestConnectivity());
}
}
private void ApplyLogOnInfoForSubreports(ReportDocument reportDocument, ConnectionInfo connectionInfo)
{
Sections sections = reportDocument.ReportDefinition.Sections;
foreach (Section section in sections)
{
ReportObjects reportObjects = section.ReportObjects;
foreach (ReportObject reportObject in reportObjects)
{
_log.InfoFormat("Type = {0}, Name = {1}",reportObject.Name, reportObject.Kind);
if (reportObject.Kind == ReportObjectKind.SubreportObject)
{
var subreportObject = (SubreportObject)reportObject;
ReportDocument subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
ApplyLogOnInfo(subReportDocument, connectionInfo);
}
}
}
}
그래서 제 질문은 다음과 같습니다
- 가 어떻게 명령에 바로 연결을 설정할 수 있습니까?
- 왜 연결을 변경할 수 없습니까? (보고서가 다른 서버에서 작성된 경우).