Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 6th, 2006, 02:33 PM
Authorized User
 
Join Date: Feb 2006
Location: Bluefields, , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MAKO
Default Passing Image File as a parameter

Hello Professionals of this forum!
I need to code a program for a server client employee record application in windows with C#. I need to learn first, how can I fill a control like a picture box on the windows form from a picture file saved on de PC, and second, how can I initialize some type of variable in code to pass that same picture as a parameter to the stored procedure that inserts each record for the employees table in my DB? Please help is greatly appreciated and needed, I'm new to C#, I'm learning, but my boss want's me to fullfil this task with no excuses. Thanks a lot in advance!


Greetings,

MAKO - "El super simio"
__________________
MAKO - \"El super simio\"
Reply With Quote
  #2 (permalink)  
Old October 7th, 2006, 04:04 AM
Friend of Wrox
 
Join Date: May 2006
Location: Delhi, Delhi, India.
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use System.Drowing.Image.
To store image in db declare field type as image->>
http://p2p.wrox.com/topic.asp?TOPIC_ID=50608

Bijgupt
Reply With Quote
  #3 (permalink)  
Old October 10th, 2006, 12:24 PM
Authorized User
 
Join Date: Feb 2006
Location: Bluefields, , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MAKO
Default

Thanks for your reply Bijgupt, it is a guiding light. However I'm still not quite clear of how can I initialize the image variable with the picture file stored in the disc. I thought of an open file dialog for the user to search for the file, but then I get confused with how to do the rest to initialize the image variable. A little bittie more help, please! Thank you!

MAKO - "El super simio"
Reply With Quote
  #4 (permalink)  
Old October 10th, 2006, 12:55 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

What you can do is, for example, place a picture box on your form with a default image then use your File Dialog and have the user select an image file. Now here is the question I have, after the use selects the image from the file dialog does that image need to be automatically placed in the picture box?

Or, after the user selects a file, do they hit submit of some sort to write the image to a database THEN the picture box has an image associated with it?

If you look at the code for your form and, assume that you have added an image to the picturebox your code will look something like:

this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictu re.ext")));

All its doing is casting the object to a type of System.Drawing.Image.

If, for example, you were to stream this file to disk as opposed to saving it to the database you could do something like this in code:

pictureBox1.Image = Image.FromFile("pic.jpg")

However, since you need to place this into a database you are going to have to write some GDI functionality that will pull the byte stream from SQL and then create an image object on the fly. (Depending on your skill set, GDI can be a bit of a challenge, but for what you need to do, it is relatively simplistic)

For example:
Bitmap bmpFile;
MemoryStream stmFile = new MemoryStream();
BinaryWriter objWriter = new BinaryWriter(stmFile);
objWriter.Write(dtImg.Rows[0][0]);
bmpFile = new Bitmap(stmFile);

I assume you pull back the data into a datatable and that the data sits at Row 0 Position 0

From there all you have to do is add it to your picture box.

hth


--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing MXML file as XML Parameter maulik33 Flex 0 January 9th, 2008 12:49 PM
passing parameter to xsl file anandjun XSLT 3 March 24th, 2006 02:46 PM
passing an image file to a .net file. sanjeet .NET Web Services 2 September 22nd, 2005 01:26 PM
passing parameter.. suzila VB.NET 2002/2003 Basics 7 May 17th, 2004 08:28 PM
Passing Parameter tgopal Javascript 3 August 7th, 2003 07:54 PM



All times are GMT -4. The time now is 05:54 PM.


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