Friday, March 23, 2012

image question

hello friends

I want to specify a field to save icons I want to give this field a maximum
of 120kb for each icon to be stored in the db.

what datatype should I assign to this field and how do I specify the size ?

Thanks
Tom"Tom" <tomgaomail@.optushome.com.au> wrote in message
news:41512fbd$0$23894$afc38c87@.news.optusnet.com.a u...
> hello friends
> I want to specify a field to save icons I want to give this field a
> maximum
> of 120kb for each icon to be stored in the db.
> what datatype should I assign to this field and how do I specify the size
> ?
> Thanks
> Tom

The image data type is the one used for large binary data, but you can't
specify a size - 2GB is the maximum allowed. Another common approach is to
leave the binary files in the filesystem, and simply store the path to the
file in a varchar column.

Simon|||I considered that option.. however storing path is not the ideal option as
many users may have the same image or icon thus resulting the same image
being sent to all users when the image are suppose to be different as the
image gets overridden when they're the same file name

any other ideas ?
thanks
Tom

"Simon Hayes" <sql@.hayes.ch> wrote in message
news:415175e2$1_2@.news.bluewin.ch...
> "Tom" <tomgaomail@.optushome.com.au> wrote in message
> news:41512fbd$0$23894$afc38c87@.news.optusnet.com.a u...
> > hello friends
> > I want to specify a field to save icons I want to give this field a
> > maximum
> > of 120kb for each icon to be stored in the db.
> > what datatype should I assign to this field and how do I specify the
size
> > ?
> > Thanks
> > Tom
> The image data type is the one used for large binary data, but you can't
> specify a size - 2GB is the maximum allowed. Another common approach is to
> leave the binary files in the filesystem, and simply store the path to the
> file in a varchar column.
> Simon|||"Tom" <tomgaomail@.optushome.com.au> wrote in message
news:41519884$0$20125$afc38c87@.news.optusnet.com.a u...
>I considered that option.. however storing path is not the ideal option as
> many users may have the same image or icon thus resulting the same image
> being sent to all users when the image are suppose to be different as the
> image gets overridden when they're the same file name
> any other ideas ?
> thanks
> Tom

<snip
Not really - those are pretty much the two options you have. Either use the
image data type and store the file in the database, or leave it in the
filesystem and store the path. It comes down to which approach is easier for
you, given your application and development environment.

Personally I'd go for the path, since then changing a user's icon just means
updating a single column, instead of loading the whole file into the
database. Also, any default or common icons only have to be stored once,
rather than maintaining a separate copy for each user.

You should also check out "Managing ntext, text, and image Data" in Books
Online, which covers the details of working with image data, and there's a
code sample for ADO, if that's what you're using.

Simon|||I had a similar problem where i wanted people to store files on my web
server, because i was worried about file name clashes i was considering
storing them in the database. Instead I came up with two ideas, one was to
put each users files into a subdirectory named after their user name, and
two the one that im using, was to first upload the file to the server, add a
database entry and return the result of the @.@.IDENTITY to my program then
preclude the name of the file with the identity value.

thus... myresume.doc would become 243_myresume.doc

Hope those help,
Muhd

"Tom" <tomgaomail@.optushome.com.au> wrote in message
news:41519884$0$20125$afc38c87@.news.optusnet.com.a u...
>I considered that option.. however storing path is not the ideal option as
> many users may have the same image or icon thus resulting the same image
> being sent to all users when the image are suppose to be different as the
> image gets overridden when they're the same file name
> any other ideas ?
> thanks
> Tom
> "Simon Hayes" <sql@.hayes.ch> wrote in message
> news:415175e2$1_2@.news.bluewin.ch...
>>
>> "Tom" <tomgaomail@.optushome.com.au> wrote in message
>> news:41512fbd$0$23894$afc38c87@.news.optusnet.com.a u...
>> > hello friends
>>> > I want to specify a field to save icons I want to give this field a
>> > maximum
>> > of 120kb for each icon to be stored in the db.
>>> > what datatype should I assign to this field and how do I specify the
> size
>> > ?
>>> > Thanks
>> > Tom
>>>>
>> The image data type is the one used for large binary data, but you can't
>> specify a size - 2GB is the maximum allowed. Another common approach is
>> to
>> leave the binary files in the filesystem, and simply store the path to
>> the
>> file in a varchar column.
>>
>> Simon
>>
>>|||thanks thats a great idea

but I'm also curious would it be possible to store the icons into a binary
field and set the size of that binary field ?

Thanks
Tom

"Muhd" <eat@.joes.com> wrote in message
news:cRj4d.493991$gE.369174@.pd7tw3no...
> I had a similar problem where i wanted people to store files on my web
> server, because i was worried about file name clashes i was considering
> storing them in the database. Instead I came up with two ideas, one was
to
> put each users files into a subdirectory named after their user name, and
> two the one that im using, was to first upload the file to the server, add
a
> database entry and return the result of the @.@.IDENTITY to my program then
> preclude the name of the file with the identity value.
> thus... myresume.doc would become 243_myresume.doc
> Hope those help,
> Muhd
>
> "Tom" <tomgaomail@.optushome.com.au> wrote in message
> news:41519884$0$20125$afc38c87@.news.optusnet.com.a u...
> >I considered that option.. however storing path is not the ideal option
as
> > many users may have the same image or icon thus resulting the same image
> > being sent to all users when the image are suppose to be different as
the
> > image gets overridden when they're the same file name
> > any other ideas ?
> > thanks
> > Tom
> > "Simon Hayes" <sql@.hayes.ch> wrote in message
> > news:415175e2$1_2@.news.bluewin.ch...
> >>
> >> "Tom" <tomgaomail@.optushome.com.au> wrote in message
> >> news:41512fbd$0$23894$afc38c87@.news.optusnet.com.a u...
> >> > hello friends
> >> >> > I want to specify a field to save icons I want to give this field a
> >> > maximum
> >> > of 120kb for each icon to be stored in the db.
> >> >> > what datatype should I assign to this field and how do I specify the
> > size
> >> > ?
> >> >> > Thanks
> >> > Tom
> >> >> >>
> >> The image data type is the one used for large binary data, but you
can't
> >> specify a size - 2GB is the maximum allowed. Another common approach is
> >> to
> >> leave the binary files in the filesystem, and simply store the path to
> >> the
> >> file in a varchar column.
> >>
> >> Simon
> >>
> >>|||Tom wrote:
> thanks thats a great idea
> but I'm also curious would it be possible to store the icons into a binary
> field and set the size of that binary field ?
> Thanks
> Tom

NO, you can't specify the size of an image columt - it's variable up to 2 GB.
Here are all the types MS SQL has:

http://www.databasejournal.com/feat...le.phpr/2212141

WYGL,
Andrey|||
As has already been stated, you can't 'set' the size of field, but since your code would load an image
into the field, it could check that the size is within limits before loading it.

--
__________________________________________________ _____
http://www.ammara.com/
Image Handling Components, Samples, Solutions and Info
DBPix 2.0 - lossless jpeg rotation, EXIF, asynchronous

"Tom" <tomgaomail@.optushome.com.au> wrote:
>thanks thats a great idea
>but I'm also curious would it be possible to store the icons into a binary
>field and set the size of that binary field ?
>Thanks
>Tom
>"Muhd" <eat@.joes.com> wrote in message
>news:cRj4d.493991$gE.369174@.pd7tw3no...
>> I had a similar problem where i wanted people to store files on my web
>> server, because i was worried about file name clashes i was considering
>> storing them in the database. Instead I came up with two ideas, one was
>to
>> put each users files into a subdirectory named after their user name, and
>> two the one that im using, was to first upload the file to the server, add
>a
>> database entry and return the result of the @.@.IDENTITY to my program then
>> preclude the name of the file with the identity value.
>>
>> thus... myresume.doc would become 243_myresume.doc
>>
>> Hope those help,
>> Muhd
>>
>>
>> "Tom" <tomgaomail@.optushome.com.au> wrote in message
>> news:41519884$0$20125$afc38c87@.news.optusnet.com.a u...
>> >I considered that option.. however storing path is not the ideal option
>as
>> > many users may have the same image or icon thus resulting the same image
>> > being sent to all users when the image are suppose to be different as
>the
>> > image gets overridden when they're the same file name
>>> > any other ideas ?
>> > thanks
>> > Tom
>>> > "Simon Hayes" <sql@.hayes.ch> wrote in message
>> > news:415175e2$1_2@.news.bluewin.ch...
>> >>
>> >> "Tom" <tomgaomail@.optushome.com.au> wrote in message
>> >> news:41512fbd$0$23894$afc38c87@.news.optusnet.com.a u...
>> >> > hello friends
>> >>> >> > I want to specify a field to save icons I want to give this field a
>> >> > maximum
>> >> > of 120kb for each icon to be stored in the db.
>> >>> >> > what datatype should I assign to this field and how do I specify the
>> > size
>> >> > ?
>> >>> >> > Thanks
>> >> > Tom
>> >>> >>> >>
>> >> The image data type is the one used for large binary data, but you
>can't
>> >> specify a size - 2GB is the maximum allowed. Another common approach is
>> >> to
>> >> leave the binary files in the filesystem, and simply store the path to
>> >> the
>> >> file in a varchar column.
>> >>
>> >> Simon
>> >>
>> >>
>>>>
>>

No comments:

Post a Comment