Category: C# General

How to retrieve a lost SQL Server Reporting Services 2005 RDL report file from a database if the source code has been lost

This is achieved using a c# application

  1. First thing to do is locate the Image column in the Catalog table in the report SQL Server database, you can look up the specific row using the itemid
  2. Then the byte array returned can be converted into a string using the code below:
AppSettingsReader config = new AppSettingsReader();
            string dbConnection = config.GetValue("DB", typeof(string)).ToString();
            SqlConnection conn = new SqlConnection(dbConnection);
            conn.Open();
            SqlCommand cmd = new SqlCommand("select content from dbo.Catalog where itemid = '70F31BA8-B6C8-4322-BB9E-89C82D2E60EC'", conn);
            cmd.CommandType = CommandType.Text;

            try
            {
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                DataSet dataset = new DataSet();
                adapter.Fill(dataset);

                using (DataTable dt = dataset.Tables["table")
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        byte[ data = (byte[)row["content";
                        textBox1.Text = System.Text.Encoding.ASCII.GetString(data);
                    

                       
                    }
                }
            }
            catch (Exception ex) {

                MessageBox.Show(ex.Message);
            }

Tags:

C#

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.