|
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
|
|
|
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?
|
|
|
|
|
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
|
|
|
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?
|
|
|
|
|
Please leave my code. Do you have any code to retreive info. like that.
eshwar
|
|
|
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
|
|
|
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
|
|
|
And,
my database(sql server) is like this
myid varchar
myname varchar
myPhoto image
of mytable.
please solve my problem
Regards,
eshwar_gp
|
|
|
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
|
|
|
|
|
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!
|
|
|
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.
|
|
|
|
|