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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:53:36+00:00 2026-05-14T00:53:36+00:00

i had sideshow ajax and i want it get images form database i used

  • 0

i had sideshow ajax and i want it get images form database
i used sql server 2000 and i had binary images

this is my code to select images from database

public class SlidShow : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        using (SqlConnection con = Connection.GetConnection())
        {
            string Sql = "Select image from SlideShowImage Where  Active=1 And Hig_Id=@Hig_Id";
            System.Data.SqlClient.SqlCommand com = new SqlCommand(Sql, con);
            com.CommandType= System.Data.CommandType.Text;
            com.Parameters.Add(Parameter.NewInt("@Hig_Id", context.Request.QueryString["Hig_ID"].ToString()));

            System.Data.SqlClient.SqlDataReader dr = com.ExecuteReader();
            if (dr.Read() && dr != null)
            {

                Byte[] bytes1 = (Byte[])dr["image"];

                context.Response.BinaryWrite(bytes1);

                dr.Close();
            }
        }
    }

  [System.Web.Services.WebMethod]
    [System.Web.Script.Services.ScriptMethod]

    public static AjaxControlToolkit.Slide[] GetSlides()
    {


        return new AjaxControlToolkit.Slide[] { 
            new AjaxControlToolkit.Slide("images/sharp_highlight_ref_img.jpg", "", ""),
             new AjaxControlToolkit.Slide("images/products_fridg_img.jpg", "", ""),
            new AjaxControlToolkit.Slide("images/sharp_home_highlight_img.jpg", "", "")


        };

    }
}
  • 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-14T00:53:37+00:00Added an answer on May 14, 2026 at 12:53 am

    I would do the image loading as a HttpHandler, which has to be registred in web.config. You don’t really need Ajax for the image loading. Your javascript code has to change the src attribute of your img tag in order to display a new image.

    Here’s an example of a http handler which loads a blog from a MS SQL db with a query parameter called id.

    public class IISHandler1 : IHttpHandler
    {
        public bool IsReusable
        {
            get { return true; }
        }
    
        public void ProcessRequest(HttpContext context)
        {
            int theID;
            if (!int.TryParse(context.Request.QueryString["id"], out theID))
                throw new ArgumentException("No parameter specified");
    
            context.Response.ContentType = "image/jpeg"; // or gif/png depending on what type of image you have
            Stream strm = DisplayImage(theID);
            byte[] buffer = new byte[2048];
            int byteSeq = strm.Read(buffer, 0, 2048);
            while (byteSeq > 0)
            {
                context.Response.OutputStream.Write(buffer, 0, byteSeq);
                byteSeq = strm.Read(buffer, 0, 2048);
            }
        }
    
        public Stream DisplayImage(int theID)
        {
            try
            {
                SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString());
                string sql = "SELECT image FROM Table1 WHERE id = @ID";
                using (SqlCommand cmd = new SqlCommand(sql, connection) { CommandType = CommandType.Text })
                {
                    cmd.Parameters.AddWithValue("@ID", theID);
                    connection.Open();
                    object theImg = cmd.ExecuteScalar();
                    return new MemoryStream((byte[]) theImg);
                }
            }
            catch
            {
                return null;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was looking at this code and had a few questions. I did some
Had to deploy some PHP code onto a shared server with only PHP5.2.8. All
I had write the following code in my Zend Form: $newpassword = new Zend_Form_Element_Password('newpassword');
Had this working; at one stage. The problem is the following text is now
I had made an application on Struts 1 with AJAX and JQuery. Now I
Had no luck getting this to work via what I found on google.
Had a search around and can't seem to find any options to do this,
had a two part question with regard to below contrived c++ code snippet :
Had a quick google to see if this can be done without much luck,
Had a bit of a is this real life moment. Why are we naming

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.