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

  • Home
  • SEARCH
  • 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 3314926
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:17:25+00:00 2026-05-17T22:17:25+00:00

Ii have a database (sql server 2008) and I am working with c# in

  • 0

Ii have a database (sql server 2008) and I am working with c# in visual studio 2010.

I want to establish a connection with my db. I have written a code for that as follows:

    SqlConnection mySqlConnection = new SqlConnection
    ("Data Source=servername\\SQL2008; Initial Catalog=MyData;UID=MyID;PWD=mypassword;");

    SqlCommand mySqlCommand = mySqlConnection.CreateCommand();
    mySqlCommand.CommandText = "SELECT image_column FROM images_table ";

    mySqlConnection.Open();

    SqlDataReader productsSqlDataReader = mySqlCommand.ExecuteReader();

I do not know how to proceed further. I mean how to extract the column from the reader after executing the above statements? Also I need to go through the entire column row by row and convert each image to an IContent item. Do I have to write my own converter for this or is there any .NET class that does this already?

Heres the scenario. I have a table with like 20 columns one of which is the images_column. That column is the ONLY column that has images stored in as binary data. The remainig columns are usual integers (its size value) and strings (its name, location, etc) associated with that particular image. I hope that it is clear now.

Thanks.

  • 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-05-17T22:17:25+00:00Added an answer on May 17, 2026 at 10:17 pm
            string conn = "Data Source=servername\\SQL2008; Initial Catalog=MyData;UID=MyID;PWD=mypassword;";
            using (SqlConnection dbConn = new SqlConnection(conn))
            {
                dbConn.Open();
                string sql = "SELECT DATALENGTH(image_column), image_column FROM images_table ";
                using (SqlCommand cmd = new SqlCommand(sql, dbConn))
                {
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int size = reader.GetInt32(0);
                            byte[] buff = new byte[size];
                            reader.GetBytes(1, 0, buff, 0, size);
                            MemoryStream ms = new MemoryStream(buff, 0, buff.Length);
                            ms.Write(buff, 0, buff.Length);
                            StoreImage(Image.FromStream(ms, true));
                        }
                    }
                }
            }
    
    • 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 database that I am querying and I only want
I have a Sql Server 2005 DB on Godaddy. I have Visual studio 2008
Our database server is a SQL 2008 server. My colleagues all have XP service
We have a legacy database which is a sql server db (2005, and 2008).
We have a database (SQL Server 2005) which we would like to get under
We have SQL Server database setup. We are setting up a replication scenarios where
I have designed database tables (normalised, on an MS SQL server) and created a
(Note: This is for MySQL's SQL, not SQL Server.) I have a database column
We have a SQL server database. To manipulate the data non-programmatically, I can use
In a SQL server database, I have a table which contains a TEXT field

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.