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 6120005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:37:07+00:00 2026-05-23T15:37:07+00:00

I have been searching for how to retrieve binary data from the database. My

  • 0

I have been searching for how to retrieve binary data from the database. My query is working fine as it shows the binary data in the SQL manager.

But in Visual Studio 2010 it just shows me <Binary Data>, which I personally think is not the problem, but if I try to retrieve it and store it in a variable it’s just empty. Any other query works as long as it has nothing to do with binary data…

And I don’t want to use a datagrid or anything as I only need it as a variable.

SqlCommand CMDbinary = new SqlCommand("SELECT Binary_field AS binary "
                                      + "FROM BIN_table", abc_conn);

SqlDataReader Bin_retriever = CMDbinary.ExecuteReader();
while (Bin_retriever.Read())
{
    BIN.Add(Bin_retriever["binary"].ToString());
}
abc_conn.Close();

I know this is not the full code, but this is where it goes wrong, I assume I have to do something special in order to display binary info, as (I’ll say it again) it works if I change Binary_field to UID (which is a varchar in the database).

Any help on this would be really welcome, Thanks in advance!

  • 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-23T15:37:08+00:00Added an answer on May 23, 2026 at 3:37 pm
     Bin_retriever["binary"].ToString()
    

    looks deadly. For binary data you can expect to get byte[] here. You can’t just call ToString() on such – you’ll probably get the type name. So, how would you want to display it? hex?

    byte[] raw = (byte[]) Bin_retriever["binary"];
    

    now format as you choose. For example:

    var builder = new StringBuilder(raw.Length * 2);
    for(int i = 0 ; i < raw.Length ; i++)
        builder.Append(raw[i].ToString("x2"));
    string hex = builder.ToString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been searching everywhere but I could not find an answer. I need
I have been searching around using Google but I can't find an answer to
How to continue from where I have been searching to find the index? I
I have a project i've been working on that requires me to retrieve the
I have been searching on how to start an applet from a servlet. Everything
I have been searching all over the Internet, but did not find that exact
I have been searching for an hour on how to use FFmpeg from .NET
Have been searching all over the internet but struggling to find my answer to
I have been searching for an answer to this but cannot find a simple
I have been searching in StackOverflow, but I only got so far this website

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.