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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:05:31+00:00 2026-05-30T18:05:31+00:00

I am pretty new to both Android and WCF. I am making a user

  • 0

I am pretty new to both Android and WCF. I am making a user table with a very small image in the sql server db as varbinary. In my service I have the following OperationContract:

        [OperationContract]
    [WebGet(UriTemplate = "users/{emailAddress}/Image", ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Bare)]
    System.IO.Stream GetImage(string emailAddress);

Implementation:

      public System.IO.Stream GetImage(string emailAddress)
   {
       //parse personID, call DB
       string query = "Select profilePic from Flows_Users WHERE emailAddress= @emailAddress";
       SqlConnection objConnection = new SqlConnection();

       DataSet ObjDataset = new DataSet();
       SqlDataAdapter objAdapater = new SqlDataAdapter();
       SqlCommand objCommand = new SqlCommand(query, objConnection);
       objCommand.Parameters.Add("emailAddress", SqlDbType.NVarChar).Value = emailAddress;
       objConnection.ConnectionString = ConfigurationManager.ConnectionStrings["ConnStr"].ToString();
       objConnection.Open();
       byte[] pic = (byte[])objCommand.ExecuteScalar();
       objConnection.Close();

       // if (pic == null)
       //     return null;

       OutgoingWebResponseContext context = WebOperationContext.Current.OutgoingResponse;

       // //if (image_not_found_in_DB)
       // //{
       // //    context.StatusCode = System.Net.HttpStatusCode.Redirect;
       // //    context.Headers.Add(System.Net.HttpResponseHeader.Location, url_of_a_default_image);
       // //    return null;
       // //}

       ////  everything is OK, so send image

       context.Headers.Add(System.Net.HttpResponseHeader.CacheControl, "public");
       context.ContentType = "image/jpeg";
       // context.LastModified = date_image_was_stored_in_database;
       context.StatusCode = System.Net.HttpStatusCode.OK;
       return new System.IO.MemoryStream(pic);
   }

Is there any way to read this into an Android Image View? I was unable to do it the base64 JSON way because the string kept terminating every time I tried to put it in a JSONArray.

Any help would be appreciated, I have been working on this since Saturday.

  • 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-30T18:05:33+00:00Added an answer on May 30, 2026 at 6:05 pm

    You are returning a MemoryStream object. Return a Base64 encoded byte array of your image instead.

    On the Android side then you can turn it back into an image and place it in your ImageView.

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

Sidebar

Related Questions

I'm using Linq2SQL and I'm pretty new to it. I've got a User table
I am pretty new to both php and SQL. I have a login page
guys. I'm pretty new to both Silverlight and WCF. What I'm trying to do
I am pretty new to image capturing using java. Which is better and easy
I'm pretty new to databases and sql. I have a problem where I have
I am pretty new to both php and mysql. I have a txt file
I'm pretty new to CakePHP and i'm running through both the Cake Book and
I'm pretty new to both Ruby and Selenium and I'm just trying to figure
So I am pretty new to both Django and Javascript (I am using JQuery)
I'm new to both of these tools, and I'm also very new to Linux

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.