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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:02:56+00:00 2026-06-12T17:02:56+00:00

following code i used to retrieve Image from database through linq query but i

  • 0

following code i used to retrieve Image from database through linq query
but i getting error like

LINQ to Entities does not recognize the method ‘System.String ToString(System.String)’ method, and this method cannot be translated into a store expression.

Error line coded with //error occurred.

public void ProcessRequest (HttpContext context) {

        HttpRequest req = context.Request;


        MembershipUser user_id1 = Membership.GetUser();
        string user_id = user_id1.ProviderUserKey.ToString();      

        // string categoryID =Convert.ToInt32("4");// req.QueryString["CategoryID"].ToString();
        // Get information about the specified category          
        TMSEntities db = new TMSEntities();
        //get User ID From Login


        var category = (from data in db.Register1_db
                       where data.User_ID == Convert.ToString(user_id)
                       select data.Student_Photo);

        //error occurred.
        int len = category.First().Length;

        // Output the binary data          
        // But first we need to strip out the OLE header          
        int OleHeaderLength = 78;
        int strippedImageLength = len - OleHeaderLength;
        byte[] imagdata = new byte[strippedImageLength];          
        Array.Copy(category.First().ToArray(), OleHeaderLength, imagdata, 0, strippedImageLength);          
        if ((imagdata) != null)          
        {              
            MemoryStream m = new MemoryStream(imagdata);              
            System.Drawing.Image image = System.Drawing.Image.FromStream(m);              
            image.Save(context.Response.OutputStream, ImageFormat.Jpeg);          
        }




}




public bool IsReusable {
    get {
        return false;
    }
}
  • 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-12T17:02:57+00:00Added an answer on June 12, 2026 at 5:02 pm

    This one should work:

    var string_id = Convert.ToString(user_id);
    var category = (from data in db.Register1_db
                           where data.User_ID == string_id
                           select data.Student_Photo);
    

    LINQ creates expressions trees, so Convert.ToString would not get called, but would have to be interpreted by the LINQ provider.

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

Sidebar

Related Questions

I used the following code to retrieve an image from a url and display
I have the following line code used to retrieve data from database: DataTable newEquipmentTable
I used the following code to select unique values from the database myCommand =
To retrieve data from ActiveDirectory I used the following code: SPSecurity.RunWithElevatedPrivileges(delegate() ( var currentDirectory
I swear the following code used to work, even in IE7 but now i
The following code is used in a query for fetching records. It uses the
The following code is used to fetch logs from app engine for further processing.
I'm using the following code to retrieve emails from my Gmail inbox. def get_mail
To retrieve the Android camera size I've used the following code: camera=Camera.open(); Parameters params
The following code I used to replace .(dot) by ,(coma) while user inputing value

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.