codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  retreive Image  eshwar_gp at 04:51 on Tuesday, November 30, 2004
 

Hi,
I am able to insert my image in database. i am doing it in asp.net with C#. Database is sqlserver. But, i am not able to display/ retrieve that image from database.

Please somebody help me.

thank you.
eshwar_gp

  Re: retreive Image  tgreer at 14:11 on Tuesday, November 30, 2004
 

At what point are you having the problem?

Do you have a query to retreive the image? Show it to us.

Does the query work, but you can't manipulate the value? Are you casting it to the correct type?

Or, is the problem that you don't know how to stream an image to the response object?



  Re: retreive Image  eshwar_gp at 10:55 on Wednesday, December 01, 2004
 

Hi:

I have to add all employees photographs into datadase. AND
Depends on project i have to retrieve their photographs with details in the given coloums like
project manager
project lead
tech writer
designers
dba
programmers
testing
............
...........


Regrds,
eshwar_gp

  Re: retreive Image  tgreer at 14:10 on Wednesday, December 01, 2004
 

Ok. So, to repeat:

At what point are you having the problem?

Please provide the details. What isn't working in your code? Is there an error, if so, what is it?



  Re: retreive Image  eshwar_gp at 14:18 on Wednesday, December 01, 2004
 

Please leave my code. Do you have any code to retreive info. like that.


eshwar

  Re: retreive Image  eshwar_gp at 04:32 on Friday, December 03, 2004
 

Hi,

my upload program is like this
------------------------------

<form id="Form1" method="post" runat="server">
<p></p>
<asp:textbox runat="server" id="Myid" />
<p></p>
<p> <asp:textbox runat="server" id="MyName" />
<p><input id="ImageFile" runat="server" type="file" NAME="ImageFile">
<p></p>
<asp:button runat="server" id="Click" Text="Click Me" />

and my display program is like this
-----------------------------------

SqlDataAdapter co = new SqlDataAdapter("select * from MyTable", c);
DataSet d = new DataSet();
co.Fill(d, "MyTable");
DataGrid1.DataSource = d.Tables["MyTable"].DefaultView;
DataGrid1.DataBind();


But, it is not giving iamge details.
i am able to see imageid and image name only.
how can i display image?
Image is stored in database like <binary>

Please Let me know how to retrive image from database.

Regards,
eshwar_gp


  Re: retreive Image  eshwar_gp at 04:32 on Friday, December 03, 2004
 

Hi,

my upload program is like this
------------------------------

<form id="Form1" method="post" runat="server">
<p></p>
<asp:textbox runat="server" id="Myid" />
<p></p>
<p> <asp:textbox runat="server" id="MyName" />
<p><input id="ImageFile" runat="server" type="file" NAME="ImageFile">
<p></p>
<asp:button runat="server" id="Click" Text="Click Me" />

and my display program is like this
-----------------------------------

SqlDataAdapter co = new SqlDataAdapter("select * from MyTable", c);
DataSet d = new DataSet();
co.Fill(d, "MyTable");
DataGrid1.DataSource = d.Tables["MyTable"].DefaultView;
DataGrid1.DataBind();


But, it is not giving iamge details.
i am able to see imageid and image name only.
how can i display image?
Image is stored in database like <binary>

Please Let me know how to retrive image from database.

Regards,
eshwar_gp


  Re: retreive Image  eshwar_gp at 04:57 on Friday, December 03, 2004
 

And,
my database(sql server) is like this

myid varchar
myname varchar
myPhoto image

of mytable.

please solve my problem

Regards,
eshwar_gp



  Re: retreive Image  tgreer at 15:04 on Friday, December 03, 2004
 

eshwar,

I've already answered this question, and posted code to show you both how to retreive the image from the database, and serve the image to a browser window. When you simply repeat the same question, I don't know what answer to give you.

Did you try the code I posted? Did it fail? If it failed, what was the error message?

tgreer


  Re: retreive Image  TZRick at 20:37 on Friday, December 17, 2004
 

Hi there!

I was doing a search for answers and came across this post. I have a similar problem. I understand how to dynamically create and display an image, but does it work the same way for a list of thumbnail photos?

Thanks!

  Re: retreive Image  tgreer at 21:26 on Friday, December 17, 2004
 

Sure. The same image-producing program can be used as the source of an indefinite number of image tags. Just paramaterize the querystring.

ASP.NET can also be used to GENERATE the thumbnail dynamically. Many JPEGs taken by digital cameras have an embedded thumbnail image. The System.Drawing namespace has methods to retrieve it. Complete code:


The C# code. What this does it get the image name off of the querystring, and looks for that image in the /pictures folder. It grabs the thumbnail from this image, and serves it via the response stream.


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Drawing.Imaging;

namespace dyn_img
{
/// <summary>
/// Summary description for thumbs.
/// </summary>
public class thumbs : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
string imageURL = Request.Params["img"];

if (imageURL.IndexOf(@"/index.html") >=0 | imageURL.IndexOf(@"\") >=0)
{
Response.End();
}

imageURL = Server.MapPath(@"pictures/") + imageURL;
System.Drawing.Image fullsizeIMG = System.Drawing.Image.FromFile(imageURL);

System.Drawing.Image.GetThumbnailImageAbort dummyCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);

System.Drawing.Image thumbnailIMG = fullsizeIMG.GetThumbnailImage(160,140,dummyCallback,IntPtr.Zero);

Response.ContentType = "image/jpeg";
thumbnailIMG.Save(Response.OutputStream, ImageFormat.Jpeg);
}

public bool ThumbnailCallback()
{
return false;
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}


I know it's pathetic, but here it is anyway: if this post was helpful, you should support CodeToad by clicking some of the sponsor links. You're also invited to my site.










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Display swf file in pdf
•  A-Line Wedding Dresses
•  Re: how to create forum using asp.net with c# language?
•  Discount coach store
•  External hard drive recovery tips
•  Create Better Maps with Global Mapper
•  Re: How to display a message box when record is temporary stored in session/grid view
•  Sharing object in perl
•  Re: C++ Beginner question


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2012