0

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

4

1 回答 1

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(); 
    }
}
于 2012-05-24T12:25:14.167 回答