 |
BOOK: Professional C#, 2nd and 3rd Editions  | This is the forum to discuss the Wrox book Professional C#, 3rd Edition by Simon Robinson, Christian Nagel, Karli Watson, Jay Glynn, Morgan Skinner, Bill Evjen; ISBN: 9780764557590 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Professional C#, 2nd and 3rd Editions section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 27th, 2004, 09:09 AM
|
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
__________________
dinesh Rana
|
|

June 2nd, 2004, 05:42 AM
|
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 2nd, 2004, 09:21 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
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.
|
|

June 3rd, 2004, 09:08 AM
|
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 5th, 2004, 12:23 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
I guess u miss a Reference. check the documentation again for that?!
Always:),
Hovik Melkomian.
|
|

March 18th, 2005, 08:35 AM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |