有没有办法将连接字符串硬编码为 RDLC?
我需要制作可以在本地处理报告的报告查看器。 我得到了带有查询的 RDL 文件。有没有办法将连接字符串插入 报告的XML代码以便报告可以直接从数据库获取数据?报告将 显示在 MS reportViewer 中。
<?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 + ' -> ' + 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。 欢迎任何其他提示或帮助,只需让它发挥作用:)
I need to make report viewer that will handle reports localy.
I got RDL files with querys. Is there a way to insert conenction string into
report's XML code so the report can get data from database directly? reports will
be display in MS reportViewer.
<?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 + ' -> ' + 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
This is RDL I have.
Any other tips or help is welcome, just need to make it work :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
RDL 文件包含未存储在 ReportViewer 控件使用的 RDLC 文件中的查询信息。如果您想在 ReportViewer 中的 SSRS 之外使用 RDL 文件,则可以在本地模式下运行报表时通过代码设置数据源属性。这样,您可以在构建数据源时将连接字符串设置为您想要的任何内容。
(显然这个片段是VB)
RDL files contain query information that isn't stored in RDLC files as used the ReportViewer control. If you want to use your RDL file outside of SSRS in the ReportViewer then you can set the datasource property from code when running the report in local mode. That way you set the connection string to whatever you want when you build the datasource.
(obviously this snippet is VB)