如何获取报告列表

时间:2012-05-24 12:25:14

标签: reporting-services

如何列出我在报表服务器中创建的所有报表?稍后我想使用此列表在我的ReportViewer控件中显示它们。

1 个答案:

答案 0 :(得分:2)

报表服务器使用名为FindObjectsNonRecursive的存储过程。

string cnxstr = "Data Source=server;Initial Catalog=ReportServer;Integrated Security=SSPI;"; //connection string
using (SqlConnection connection = new SqlConnection(cnxstr))
{
    connection.Open(); 
    SqlCommand command = new SqlCommand();
    command.Connection = connection; 
    command.CommandType = CommandType.StoredProcedure; 
    command.CommandText = "FindObjectsNonRecursive";
    command.Parameters.Add(new SqlParameter("@Path", "/folder_name"));
    command.Parameters.Add(new SqlParameter("@AuthType", 1));
    SqlDataReader reader = null; 
    try
    {
        reader = command.ExecuteReader(); 
        while (reader.Read())
        {
            string path = reader["Path"].ToString(); 
            //now you can display this path in your list, or do whatever
        }
    }
    finally
    {  
        if (reader != null) 
            reader.Close(); 
    }
}