Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8506573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:37:39+00:00 2026-06-11T02:37:39+00:00

I have a SQL Server 2008-R2 database that has a table that is storing

  • 0

I have a SQL Server 2008-R2 database that has a table that is storing different types of files (Word Docs, PDF, TIF, etc), I can successfully retrieve these files from the database using the following method:

private void GetFilesFromDatabase() {
            try
            {

                const string connStr = @"Data Source=localhost\SQLInstance;Initial Catalog=MyData;Integrated Security=True;";

                //Initialize SQL Server connection.
                SqlConnection CN = new SqlConnection(connStr);

                //Initialize SQL adapter.
                SqlDataAdapter ADAP = new SqlDataAdapter("Select ole_id, ole_object From OLE Where ole_id = 21601", CN);

                //Initialize Dataset.
                DataSet DS = new DataSet();

                //Fill dataset with FilesStore table.
                ADAP.Fill(DS, "FilesStore");

                //Get File data from dataset row.
                byte[] FileData = (byte[])DS.Tables["FilesStore"].Rows[0]["ole_object"];

                string FileName = @"C:\Temp\Text.doc";
                //Write file data to selected file.
                using (FileStream fs = new FileStream(FileName, FileMode.Create))
                {
                    fs.Write(FileData, 0, FileData.Length);
                    fs.Close();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

This file I am retrieving is a Word Doc file according to other information contained in that particular row. When I attempt to open the file after retrieving it to disk the data all appears to be gibberish and is not able to be read. Now I believe that these files were compressed prior to be saved to the database but I don’t know how to de-compress them so that they can be viewed, any thoughts on how I may accomplish this? My ultimate goal is to move these images into another database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:37:41+00:00Added an answer on June 11, 2026 at 2:37 am

    Your code to save files look OK. Assuming your original data was .DOC file and you got bad file after saving you pretty much out of luck. You may want to look at the content of the file in binary editor (i.e. Visual Studio’s one) to confirm that file is not something obviously different (text/image….).

    You need to ask around how files where stored in the database. There is no way this can be answered remotely as it could be compressed, encrypted, split into chunks or even simply corrupted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL Server 2008 database with a table that has a column
I have a database table (SQL Server 2008 R2 Express edition) that has a
I use SQL Server 2008. I have a database (Database1) that has one table
I have a SQL Server 2008 database with a table that has a column
We have a SQL Server 2008 database that has stored procedures to handle reads/writes/etc.
I have a SQL Server 2008 database. This database has a stored procedure that
I have a SQL Server 2008 database that has two tables. These two tables
I have a SQL Server 2008 database with a table that contains a FILESTREAM
I have a SQL Server 2008 database. This database has a column that represents
I have SQL Server 2008 database with 2 tables: Table A has columns ID

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.