如何列出我在报表服务器中创建的所有报表?稍后我想使用此列表在我的ReportViewer
控件中显示它们。
答案 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();
}
}