Sunday, February 12, 2012

Adding an image

Hi, I have a pretty simple question. I have a table, and I need one of my columns to be an 'image' column. I've set the column type to 'image', but now I don't know how to actually add images to that column. Can someone please help me.

Hello, SuperNove289 (wow! :)

Simple question- simple answer:

Assume, you have this Table_1 with SelectedImages and Path fields.

CREATE TABLE [dbo].[Table_1](

[SelectedImages] [image] NOT NULL,

[Path] [ntext] NOT NULL

)

to add an image, do this:

INSERT INTO [testing].[dbo].[Table_1]

([SelectedImages]

,[Path])

VALUES

('D:\desktop\05022006\free_chart1.gif' ,'D:\desktop\05022006\free_chart1.gif' )

So, then you will do this :

SELECT [SelectedImages]

,[Path]

FROM [testing].[dbo].[Table_1]

You will get something like this:( <Binary data>)

SelectedImages Path

- -

0x443A5C6465736B746F705C30353032323030365C667265655F6368617274312E676966 D:\desktop\05022006\free_chart1.gif

(1 row(s) affected)

Probably the next question will be is how to see the entered image J

|||

Hi SuperNova,

As suggested you may definately add images to your database but this is not the best practise you should avoid such BLOB operation refer http://research.microsoft.com/research/pubs/view.aspx?msr_tr_id=MSR-TR-2006-45 research done at MS, instead store file path of documents and handle it from Front End Applciation.

HTH

Hemantgiri S. Goswami

|||That depends on your coding language how to upload the data to the server, for C#, see this sample which is quite simple.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=622943&SiteID=1

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

No comments:

Post a Comment