Display Image in gridview store in database
-
Hi Coders My Problem is that Image store in database in binary format and I want to display in a gridview but unable 2 do so. If u do this with use of LINQ that is best for me.Anyway u are free to do this with any method. any help would be appreciated Thanks Amit Gautam
-
Hi Coders My Problem is that Image store in database in binary format and I want to display in a gridview but unable 2 do so. If u do this with use of LINQ that is best for me.Anyway u are free to do this with any method. any help would be appreciated Thanks Amit Gautam
gautamamit8 wrote:
f u do this with use of LINQ that is best for me.
Then You have to post in job task..!This forum is for helping to others not to do their work ..! If You are stuck with some where then we can help you..! What You had done until now ..?Where did you stuck..! try this link..! Displaying Image in Gridview from Database[^]
LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.
-
Hi Coders My Problem is that Image store in database in binary format and I want to display in a gridview but unable 2 do so. If u do this with use of LINQ that is best for me.Anyway u are free to do this with any method. any help would be appreciated Thanks Amit Gautam
Refer this article C# Image to Byte Array and Byte Array to Image Converter Class[^]
-
gautamamit8 wrote:
f u do this with use of LINQ that is best for me.
Then You have to post in job task..!This forum is for helping to others not to do their work ..! If You are stuck with some where then we can help you..! What You had done until now ..?Where did you stuck..! try this link..! Displaying Image in Gridview from Database[^]
LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.
Till now I store the single image in binary format in database. Even , I can show the image from database single but I dont know how to show them in Grid. The Article Link u given to me is for display image via using path of the Image not in binary format.So that is not helpful and Secondly I'm not here to get complete my work from others I just need a help or a point where i can solve my problem. Thanks for urs kind interest Amit
-
Till now I store the single image in binary format in database. Even , I can show the image from database single but I dont know how to show them in Grid. The Article Link u given to me is for display image via using path of the Image not in binary format.So that is not helpful and Secondly I'm not here to get complete my work from others I just need a help or a point where i can solve my problem. Thanks for urs kind interest Amit
-
Refer this article C# Image to Byte Array and Byte Array to Image Converter Class[^]
sorry dear can't work
-
sorry dear can't work
What is the error that you are getting??
-
What is the error that you are getting??
-
Hi Coders My Problem is that Image store in database in binary format and I want to display in a gridview but unable 2 do so. If u do this with use of LINQ that is best for me.Anyway u are free to do this with any method. any help would be appreciated Thanks Amit Gautam
//upload image public void OnUpload(Object sender, EventArgs e) { int len = Upload.PostedFile.ContentLength; byte[] pic = new byte[len]; Upload.PostedFile.InputStream.Read (pic, 0, len); SqlConnection connection = new SqlConnection (@"server=INDIA INDIA;database=iSense;uid=sa;pwd=india"); try { connection.Open (); SqlCommand cmd = new SqlCommand ("insert into Image " + "(Picture, Comment) values (@pic, @text)", connection); cmd.Parameters.Add ("@pic", pic); cmd.Parameters.Add ("@text", Comment.Text); cmd.ExecuteNonQuery (); } finally { connection.Close (); } } //load image private void Page_Load(object sender, System.EventArgs e) { 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 where id"], 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); } catch { string strblandImagePath = Server.MapPath(""); strblandImagePath += "NoImg.gif"; FileStream FileBlandImagestream = File.OpenRead(strblandImagePath); Bitmap bitImage = new Bitmap(FileBlandImagestream); Response.ContentType = "image/gif"; bitImage.Save(Response.OutputStream, ImageFormat.Gif); } finally { connection.Close (); stream.Close (); } }