I had sidehow ajax and I want it to get the image database I used sql server 2000 and I had binary images
this is my code for selecting images from the 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", "", "")
};
}
}
source
share