Tuesday 17 August 2010

Jak pobrać listę raportów ?

Okazuje się to bardzo proste. Report server wykorzystuje do tego procedurę składowaną FindObjectsNonRecursive.


string cnxstr = "Data Source=moja_nazwa_serwera;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", "/nazwa_mojego_folderu"));
    command.Parameters.Add(new SqlParameter("@AuthType", 1));
    SqlDataReader reader = null
    try
    {
        reader = command.ExecuteReader(); 
        while (reader.Read())
        {
            string sciezka = reader["Path"].ToString(); 
            //teraz możesz np. wyświetlić ją na liście
        }
    }
    finally
    {  
        if (reader != null
            reader.Close(); 
    }
}

No comments:

Post a Comment