Sunday, February 19, 2012

About receiving an image from SQL server 2000 and displaying it in aspx page..............

hi friends,

i need a code for storing and receiving an image to/fro SQL SERVER 2000 (in C#). i had searched some sites, all are in VB for windows forms not for website. finally i got a code from some site. it is working for storing purpose. not working for receiving purpose. the code for receiving and displaying purpose is

(in a fresh page)

privatevoid Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
MemoryStream stream =new MemoryStream ();
SqlConnection connection =new
SqlConnection (@."server=INDIA\INDIA;database=iSense;uid=sa;pwd=india");
try
{
connection.Open ();
SqlCommand command =new
SqlCommand ("select Picture from Image", connection);
byte[] image = (byte[]) command.ExecuteScalar ();
stream.Write (image,0, image.Length);
Bitmap bitmap =new Bitmap (stream);
Response.ContentType ="image/gif";
bitmap.Save (Response.OutputStream, ImageFormat.Gif);
}
finally
{
connection.Close ();
stream.Close ();
}
}


what s the problem is.......i'm getting an exception at Bitmap instantiation.

(i.e Bitmap bitmap =new Bitmap (stream);)

exception is "Parameter is not valid"

what is the problem with that coding? was it correct? do u have any code for this in C#? if so, pls provide that.....help me......pls..........

Have a look at

http://www.codeproject.com/aspnet/NetPix.asp This article explains an ASP.NET application to view and share photos online.
|||

i got the answer from

http://www.ftponline.com/vsm/2002_07/online/hottips/esposito/

in that program setoffset =0;(they have coded as 78,it will not work.) this is very very important.......now i'm so happy........after a month i got the answer.....

No comments:

Post a Comment