Wednesday, March 21, 2012

How can I add pictures to my database filed in design view?

I have a database called 'Objects' which has many field. One of its fields is called 'Image' and has a data type image.

I want to add pictures to each one of my records offline, is this possible?

i.e. by copying the address from my C drive such as C:\Documents and Settings\fseyedarabi\My Documents\My Pictures

Hi,

From your description, it seems that you want to upload your local image file to the image field in your database, right?

If so, I suggest that you can refer the FileUpload class, The FileUpload class displays a text box control and a browse button that allow users to select a file on the client and upload it to the Web server. The user specifies the file to upload by entering the full path to the file on the local computer (for example, C:\MyFiles\FileName) in the text box of the control. Alternately, the user can select the file by clicking the Browse button, and then locating it in the Choose File dialog box.

After that, just read the file into binary format and save it into the corresponding data filed of your database.

For more information, see:
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload(VS.80).aspx

Thanks.

No comments:

Post a Comment