2011-08-11 3 views
0

나는 localy 보고서를 처리 할 보고서 뷰어를 만들어야합니다. QLys가있는 RDL 파일이 있습니다. 보고서가 데이터베이스에서 직접 데이터를 가져올 수 있도록 보고서의 XML 코드에 공백 문자열을 삽입하는 방법이 있습니까? 보고서 은 MS reportViewer에 표시됩니다.RDLC에 연결 문자열을 하드 코딩 할 수 있습니까?

<?xml version="1.0" encoding="utf-8"?> 
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"> 
    <DataSources> 
    <DataSource Name="BIA"> 
     <DataSourceReference>BIA</DataSourceReference> 
     <rd:DataSourceID>98fa74a9-d829-4196-be9d-49697ded5201</rd:DataSourceID> 
    </DataSource> 
    </DataSources> 
    <DataSets> 
    <DataSet Name="RelItems"> 
     <Fields> 
     <Field Name="RelItemID"> 
      <DataField>RelItemID</DataField> 
      <rd:TypeName>System.Int32</rd:TypeName> 
     </Field> 
     <Field Name="SSISPackageName"> 
      <DataField>SSISPackageName</DataField> 
      <rd:TypeName>System.String</rd:TypeName> 
     </Field> 
     </Fields> 
     <Query> 
     <DataSourceName>BIA</DataSourceName> 
     <CommandText>select b.ID as RelItemID, SSISPName --+ ' ('+s.Name + ' -&gt; ' + d.Name + ')' 
as SSISPackageName 
    from dbo.RelTypes_ProvTypes a 
    inner join dbo.RelItems b on a.RelTypeID = b.RelTypeID 
    inner join dbo.ObjItems s on b.ObjItemIDSource = s.ID and a.ObjTypeIDSource = s.ObjTypeID 
    inner join dbo.ObjItems d on b.ObjItemIDDest = d.ID and a.ObjTypeIDDest = d.ObjTypeID 
where SSISPName is not null 
order by 2</CommandText> 
     <rd:UseGenericDesigner>true</rd:UseGenericDesigner> 
     </Query> 
    </DataSet> 

... and so on 

이것은 RDL입니다. 다른 도움말이나 도움을 환영합니다. 그냥 작동시켜야합니다.

답변

1

RDL 파일에는 ReportViewer 컨트롤로 RDLC 파일에 저장되지 않은 쿼리 정보가 들어 있습니다. ReportViewer에서 SSRS 외부에서 RDL 파일을 사용하려는 경우 로컬 모드에서 보고서를 실행할 때 코드에서 데이터 소스 속성을 설정할 수 있습니다. 그렇게하면 데이터 소스를 빌드 할 때 원하는대로 연결 문자열을 설정할 수 있습니다.

ReportViewer1.Reset() 
ReportViewer1.LocalReport.DataSources.Clear() 
ReportViewer1.LocalReport.ReportPath = <yourfilepath> 
ReportViewer1.LocalReport.DataSources.Add(<yourdatasource>) 
ReportViewer1.LocalReport.Refresh() 

응답에

+0

TNX을 (분명이 조각은 VB입니다) ... 문제는 새로운 보고서가 그래서 보고서 내에서 SQL을 사용하려면 앱에 추가 할 수 있다는 것입니다. 새로운 보고서가 추가 될 때마다 모든 데이터 세트에 코드를 추가하는 것은 큰 일입니다. 데이터 소스에서 연결 문자열을 추가 할 수 있다는 것을 알았습니다. 하지만 잘못된 것을하는 데 도움이 될 수 있습니다. <데이터 소스 이름 = "XXX"> 98fa74a9-d829-4196-be9d-49697ded5201 SQL <커넥트> ... IntegratedSecurity> true DB 연결하려고합니다. MS – Tom

+0

잘못된 것일 수 있지만 RDLC 파일로 원하는 작업을 수행 할 수 없습니다. 연결 문자열 요소는 RDLC 파일에서 사용되지 않으므로 ReportViewer.LocalReport 수준에서 연결을 설정해야하는'/ * Local Connection */'으로 설정됩니다. –

+0

나는 당신이 옳다는 것을 두려워한다. 그래서 databese에서 데이터를 읽어서 중간에 어떤 C# 코드도없이 직접적으로보고 할 수있는 방법이 없다? – Tom

관련 문제