p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional C#, 2nd and 3rd Editions (http://p2p.wrox.com/forumdisplay.php?f=44)
-   -   IMAGE Data type (http://p2p.wrox.com/showthread.php?t=13497)

ranakdinesh May 27th, 2004 09:09 AM

IMAGE Data type
 
I have datafiled Photo with datatype Image in sql server . i want to use it to store Image. how i canwrite a code in windows Application using C# to insert and retrive image from the database to viev it on a Picture t control. please provide me few lines of sample code


dinesh Rana

melvik May 29th, 2004 12:11 AM

Insure it will help u much.
http://www.codeproject.com/cs/database/albumviewer.asp

Always:),
Hovik Melkomian.

ranakdinesh June 2nd, 2004 05:42 AM

what is the error in this code whenever i i run the code i recieve an error at Bitmap bmp = new Bitmap(stream);
as addtional inforamtion



string strcmd = string.Format("select photo from employee where employeeid = '1199'");
SqlCommand cmd =new SqlCommand(strcmd,conn);
byte[] b = (byte[])cmd.ExecuteScalar();
    if(b.Length > 0)
{

System.IO.MemoryStream stream = new System.IO.MemoryStream(b, true); stream.Write(b, 0, b.Length);

        Bitmap bmp = new Bitmap(stream);


                //if(bmp.Width>500 && bmp.Height >300)
                {
                // Bitmap bmp1 = new Bitmap(bmp,new Size(500,300));
                // photo.Image = bmp1;
                }
                //else
                {
                // photo.Image = bmp;
                }



            }
        conn.Close();
        }

dinesh Rana

melvik June 2nd, 2004 09:21 AM

It works fine dear. Did u edited the codes?!
What is this?!
Code:

                //if(bmp.Width>500 && bmp.Height >300)
                {
                //    Bitmap bmp1 = new Bitmap(bmp,new Size(500,300));
                //    photo.Image = bmp1;
                }
                //else
                {
                //    photo.Image = bmp;
                }



Always:),
Hovik Melkomian.

ranakdinesh June 3rd, 2004 09:08 AM

i inserted the photographs in the server sucess fully but when i want to retrive photographs back from the server it gives me an error
invalid arguments at


Bitmap bmp = new Bitmap(stream)
i tried it in number of ways but i wont get it.

Please help me to get out of this

dinesh Rana

melvik June 5th, 2004 12:23 AM

I guess u miss a Reference. check the documentation again for that?!

Always:),
Hovik Melkomian.

ravisrikrishna March 18th, 2005 08:35 AM

I Need to create a table in which I have to add Image Datatype column.My environment is win 2000 and SQL server 2000.front end is VB.Net.I need this at the earliest.How to ad a .jpeg file into that table using blobs.
regards
ravi


All times are GMT -4. The time now is 08:47 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.