Click here to Skip to main content
15,918,596 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: About DataGrid Pin
Jintal Patel3-Jun-08 3:12
Jintal Patel3-Jun-08 3:12 
Questionreport Viewer Pin
eyeseetee3-Jun-08 0:43
eyeseetee3-Jun-08 0:43 
QuestionAbout DataGrid Pin
EzhilarasiMSc3-Jun-08 0:12
EzhilarasiMSc3-Jun-08 0:12 
AnswerRe: About DataGrid Pin
eyeseetee3-Jun-08 0:46
eyeseetee3-Jun-08 0:46 
Questiondynamically assigning connection string name to membership provider at Runtime Pin
neilsuresh2-Jun-08 23:58
neilsuresh2-Jun-08 23:58 
AnswerRe: dynamically assigning connection string name to membership provider at Runtime Pin
eyeseetee3-Jun-08 0:45
eyeseetee3-Jun-08 0:45 
QuestionCrystal Report in ASP.NET Pin
senthilsstil2-Jun-08 23:40
senthilsstil2-Jun-08 23:40 
QuestionHow to retrieve images from SQL SERVER 2005 on to an ASP.NET page in C# Pin
SinghSu2-Jun-08 23:07
SinghSu2-Jun-08 23:07 
Hello Friends,
Error: I am not able to load the image on the page every time I get an Red X mark

Question: Can anyone help me identifying the error from the code that I am using to retrieve the image from the SQLSERVER2005 on to an ASP.NET PAGE in C#
Code for DisplayPhoto.aspx.cs:
protected void Page_Init(object sender, EventArgs e)
{
SqlConnection SqlConnection1 = new SqlConnection();
string connstring = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
SqlConnection1.ConnectionString = connstring;
SqlConnection1.Open();

if (Request.QueryString["id"] != null)
{
int id;

if (Int32.TryParse(Request.QueryString["id"], out id))
{
Response.Clear();
Response.ContentType = "image/jpeg";

System.Drawing.Image image1 = RetrieveImage(id);
image1.Save(Response.OutputStream, ImageFormat.Jpeg);
}
}
}
private System.Drawing.Image RetrieveImage(int photoId)
{
System.Drawing.Image image2 = null;
System.Data.SqlClient.SqlCommand cmd_selectphoto = new System.Data.SqlClient.SqlCommand();
cmd_selectphoto.Connection = SqlConnection1;
cmd_selectphoto.CommandType = CommandType.Text;
cmd_selectphoto.CommandText = "SELECT PhotoImage FROM Photo WHERE PhotoID = 5";
//cmd_selectphoto.Parameters.AddWithValue("3", photoId);
byte[] imageData = (byte[])cmd_selectphoto.ExecuteScalar();

MemoryStream memStream = new MemoryStream(imageData);
image2 = System.Drawing.Image.FromStream(memStream);
return image2;
}
Code for DisplayPhoto.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DisplayPhoto.aspx.cs" Inherits="DisplayPhoto" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<%-- <link href="Admin.css" type="text/css" rel="stylesheet" />--%>
<title>Display Photo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<center>
<table width="80%" style="height: 62px" cellspacing="0" cellpadding="0" border="0"
class="table">
<tr>
<td>
<asp:Image ID="image1" runat="server" />
</td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>
AnswerRe: How to retrieve images from SQL SERVER 2005 on to an ASP.NET page in C# Pin
Christian Graus3-Jun-08 2:14
protectorChristian Graus3-Jun-08 2:14 
GeneralRe: How to retrieve images from SQL SERVER 2005 on to an ASP.NET page in C# Pin
SinghSu3-Jun-08 20:34
SinghSu3-Jun-08 20:34 
QuestionHow to Identify that Connected database is MySql, Sql Express, Sql Server 2000, etc. Pin
pandeybrijendra2-Jun-08 23:04
pandeybrijendra2-Jun-08 23:04 
QuestionMultiple Gridview mantaining LINQ relationships Pin
Ponzano Paolo2-Jun-08 21:43
Ponzano Paolo2-Jun-08 21:43 
Questionhow to associate event handler for dynamically created dropdownlist Pin
vidhyap2-Jun-08 21:35
vidhyap2-Jun-08 21:35 
AnswerRe: how to associate event handler for dynamically created dropdownlist Pin
eyeseetee2-Jun-08 21:58
eyeseetee2-Jun-08 21:58 
AnswerRe: how to associate event handler for dynamically created dropdownlist Pin
N a v a n e e t h2-Jun-08 22:15
N a v a n e e t h2-Jun-08 22:15 
GeneralRe: how to associate event handler for dynamically created dropdownlist Pin
vidhyap2-Jun-08 23:34
vidhyap2-Jun-08 23:34 
GeneralRe: how to associate event handler for dynamically created dropdownlist Pin
N a v a n e e t h3-Jun-08 0:01
N a v a n e e t h3-Jun-08 0:01 
GeneralRe: how to associate event handler for dynamically created dropdownlist Pin
vidhyap3-Jun-08 0:14
vidhyap3-Jun-08 0:14 
GeneralRe: how to associate event handler for dynamically created dropdownlist Pin
N a v a n e e t h3-Jun-08 1:02
N a v a n e e t h3-Jun-08 1:02 
GeneralRe: how to associate event handler for dynamically created dropdownlist Pin
vidhyap3-Jun-08 18:18
vidhyap3-Jun-08 18:18 
GeneralRe: how to associate event handler for dynamically created dropdownlist Pin
N a v a n e e t h4-Jun-08 3:48
N a v a n e e t h4-Jun-08 3:48 
AnswerRe: how to associate event handler for dynamically created dropdownlist Pin
Baran M3-Jun-08 3:24
Baran M3-Jun-08 3:24 
GeneralRe: how to associate event handler for dynamically created dropdownlist Pin
vidhyap3-Jun-08 17:03
vidhyap3-Jun-08 17:03 
Questionajaxtoolkit problem Pin
Miss Maheshwari2-Jun-08 21:23
Miss Maheshwari2-Jun-08 21:23 
AnswerRe: ajaxtoolkit problem Pin
eyeseetee2-Jun-08 21:57
eyeseetee2-Jun-08 21:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.