Reporting Services 报表的数据检索问题疑难解答Troubleshoot Data Retrieval issues with Reporting Services Reports

报表处理的第一步是通过运行数据集查询检索每个数据集的报表数据。The first step during report processing is to retrieve the report data for each dataset by running the dataset query. 本地预览报表时,数据源连接和凭据必须使用足够的权限才能检索计算机上的数据。When you preview a report locally, your data source connections and credentials must use sufficient permissions to retrieve the data to your computer. 在报表服务器上运行报表时,数据源连接和凭据必须使用足够的权限才能检索报表服务器上的数据。When you run a report on the report server, the data source connections and credentials must use sufficient permissions to retrieve the data on the report server. 使用本主题可帮助解决有关报表数据检索的问题。Use this topic to help troubleshoot issues about report data retrieval.

无法与数据源建立连接I cannot create a connection to a data source

创建数据源、运行数据集查询或预览报表时,你可能会收到以下消息:无法与数据源 <data source name> 建立连接。When you create a data source, run a dataset query, or preview a report, you might get the following message: Cannot create a connection to data source <data source name>.

数据源不可用。Data Source is Not Available.

数据源由于其他某种原因脱机或不可用。The data source is offline or unavailable for some other reason.

请确认您有权访问该数据源,并且该数据源可用。Verify that you have access to the data source and that it is available. 例如,使用 Sql Server Management Studio 连接数据源。For example, use Sql Server Management Studio to connect to the data source. 对于关系数据库和多维数据库,请使用“连接属性” 对话框中的“测试” 按钮来验证与数据源的连接和对数据源的权限。For relational databases and multidimensional database, use the Test button on the Connection Properties dialog box to verify the connection and permissions to the data source.

数据源凭据无效。Data Source Credentials are Not Valid.

您用来连接数据源的凭据没有足够权限来检索查询中指定的数据。The credentials that you are using to connect to the data source have insufficient permissions to retrieve the data specified in the query.

请确认使用的凭据正确。Verify that the credentials that you are using the correct credentials. 例如,您可能有权从表或视图检索数据,但不能检索特定列的数据;或者您可能没有足够权限运行填充视图的存储过程。For example, you may have permission to retrieve data from a Table or View, but not for a specific column; or you might not have sufficient permissions to run a stored procedure that populates a view.

备注

检索用于预览报表的数据所需的权限可能与将报表发布到报表服务器之后检索数据时所需的权限不同。Permissions that you use to retrieve data for previewing a report may be different than permissions that are needed to retrieve data after a report is published to a report server.

密码无效Not a Valid Password

对于具有提示凭据或在连接字符串中指定的凭据的数据源,密码的字符会传递给基础数据源驱动程序。For data sources with prompted credentials or credentials specified in the connection string, the characters for the password are passed to the underlying data source drivers. 如果密码或字符串包含特殊字符(如引号),则某些数据源驱动程序将无法验证这些特殊字符。If the password or string contains special characters like punctuation marks, some data source drivers cannot validate the special characters.

确认密码不包含特殊字符。Verify that the password does not include special characters. 如果不能更改密码,则可以请数据库管理员将相应的凭据作为系统 ODBC 数据源名称 (DSN) 的一部分存储在本地和服务器中。If changing the password is impractical, work with your database administrator to store the appropriate credentials locally and on the server as part of a system ODBC data source name (DSN). 有关详细信息,请参阅 MSDN 上的 .NET Framework SDK 文档中的“OdbcConnection.ConnectionString”。For more information, see "OdbcConnection.ConnectionString" in the .NET Framework SDK documentation on MSDN.

备注

建议您不要在连接字符串中添加登录信息(如密码)。It is recommended that you do not add login information such as passwords to the connection string. 报表设计器在“数据源属性”或“共享数据源属性”对话框上提供“凭据”页,可在其中输入凭据 。Report Designer provides a Credentials page on the Data Source Properties or the Shared Data Source Properties dialog boxes that you can use to enter credentials. 这些凭据安全地存储在报表创作计算机上。These credentials are stored securely on the report authoring computer.

在查询设计器中运行查询时为什么看不到数据?Why do I see no data when I run my query in the query designer?

创建数据集时,数据集字段集合将显示在“报表数据”窗格中。When you create a dataset, the dataset field collection appears in the Report Data pane. 有时候,数据集字段集合不按预期的方式显示。Sometimes the dataset field collection does not appear as expected.

导入查询不导入计算字段Import Query Does Not Import Calculated Fields

尽管计算字段保存在报表定义中,但从其他报表中导入数据集查询时不会包含这些字段。Although calculated fields are saved in a report definition, they are not included when you import a dataset query from another report. 如果通过从其他报表导入查询来创建数据集,则仅该数据集查询指定的字段会显示在“报表数据”窗格中。Only fields specified by the dataset query appear in the Report Data pane after you create a dataset by importing a query from another report.

若要在“报表数据”窗格中查看计算字段,必须为使用计算字段的每个报表定义计算字段。To view calculated fields in the Report Data pane, you must define them for each report in which they are used.

有些数据访问接口不支持自动填充数据集字段集合Some Data Providers Do Not Support Automatic Population of the Dataset Field Collection

在“数据集属性”对话框中定义查询时,关闭该对话框后,数据集字段集合通常会显示在“报表数据”窗格中。When you define a query in the Dataset Properties dialog box, and then close the dialog box, the dataset field collection usually appears in the Report Data pane. 对于某些数据源,不会自动填充数据集字段集合。For some data sources, the dataset field collection is not automatically populated.

若要填充数据集字段集合,请执行以下操作:To populate the dataset field collection, do the following:

  • 确保您具有从数据库中检索字段信息的权限。Make sure that you have permissions to retrieve field information from the database. 对于某些数据源,可能有权访问数据源,但无权访问表或列。For some data sources, you might have permissions to access the data source but not the table or column. 您可能有权访问视图,但无权运行创建视图的存储过程。You may have permission to access a view but not the permissions to run the stored procedures that create the view. 若要验证你是否具有访问数据库中特定表或列的权限,请使用用于报表的相同权限,在一个单独的应用程序(例如 SQL Server Management Studio)中验证查询结果。To validate your access to specific tables or columns in a database, verify your query results in a separate application such as SQL Server Management Studio using the same permissions you use for the report. 如果看不到查询需要的结果,请与系统管理员联系调整您的数据访问权限。If you cannot see the results that you want for your query, work with the system administrator to adjust your permissions to the data.
  • 在“数据集属性” 对话框的查询窗格中运行该查询。Run the query in the query pane of the Dataset Properties dialog box. 有关详细信息,请参阅 报表数据集(Report Builder 3.0 和 SSRS)For more information, see Report Datasets (Report Builder 3.0 and SSRS).
  • 手动添加字段。Add fields manually. 有关详细信息,请参阅操作说明:在“报表数据”窗格中添加、编辑和刷新字段(Report Builder 3.0 和 SSRS)For more information, see How to: Add, Edit, Refresh Fields in the Report Data Pane (Report Builder 3.0 and SSRS).

另请参阅See Also

错误和事件 (Reporting Services)Errors and events (Reporting Services)

是否需要帮助?是否需要帮助? Microsoft 问答StackoverflowSQL Server 产品反馈Need help? Need help? Microsoft Q & A, Stackoverflow, SQL Server product feedback