By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,489 Members | 3,084 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,489 IT Pros & Developers. It's quick & easy.

Need help displaying JPG where filename is from DB Query

P: n/a
I have a list of JPG's which are found in a SQL Server database. When the
page selects a certain piece of data it will refer to the file system
(resident on IIS server with a virtual directory) and files contained within
a certain folder. I have been trying for quite a while to set the ImageURL
of an image control to the correct information.

I have googled till my mind hurts but can find nothing to help. I have even
tried to copy the jpg file to a temppics folder under my site to make that
work with no luck. Just the gif showing the file does not exist.
For example this is the filename of one of the jpgs:

D:\My Music\Classic Rock\Devo - Oh, No! It's Devo\Devo - Oh, No! It's
Devo.jpg

I put this into the ImageURL of the image control. When I look at the
properties of the image from the displayed page the URL ends up being
Devo%2520-%2520Oh,%2520No!%2520It's%2520Devo.jpg.

I am very confused ( a normal thing ) but really need a push in the right
direction here.

Thanks

Lloyd Sheen

Jun 7 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Here I've detailed all the steps you need to store and retrieve images in a
sql server database:
http://SteveOrr.net/articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net

"Lloyd Sheen" <a@b.cwrote in message
news:02**********************************@microsof t.com...
>I have a list of JPG's which are found in a SQL Server database. When the
page selects a certain piece of data it will refer to the file system
(resident on IIS server with a virtual directory) and files contained
within a certain folder. I have been trying for quite a while to set the
ImageURL of an image control to the correct information.

I have googled till my mind hurts but can find nothing to help. I have
even tried to copy the jpg file to a temppics folder under my site to make
that work with no luck. Just the gif showing the file does not exist.
For example this is the filename of one of the jpgs:

D:\My Music\Classic Rock\Devo - Oh, No! It's Devo\Devo - Oh, No! It's
Devo.jpg

I put this into the ImageURL of the image control. When I look at the
properties of the image from the displayed page the URL ends up being
Devo%2520-%2520Oh,%2520No!%2520It's%2520Devo.jpg.

I am very confused ( a normal thing ) but really need a push in the right
direction here.

Thanks

Lloyd Sheen
Jun 7 '07 #2

P: n/a

"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.netwrote in
message news:7F**********************************@microsof t.com...
Here I've detailed all the steps you need to store and retrieve images in
a sql server database:
http://SteveOrr.net/articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net

"Lloyd Sheen" <a@b.cwrote in message
news:02**********************************@microsof t.com...
>>I have a list of JPG's which are found in a SQL Server database. When the
page selects a certain piece of data it will refer to the file system
(resident on IIS server with a virtual directory) and files contained
within a certain folder. I have been trying for quite a while to set the
ImageURL of an image control to the correct information.

I have googled till my mind hurts but can find nothing to help. I have
even tried to copy the jpg file to a temppics folder under my site to
make that work with no luck. Just the gif showing the file does not
exist.
For example this is the filename of one of the jpgs:

D:\My Music\Classic Rock\Devo - Oh, No! It's Devo\Devo - Oh, No! It's
Devo.jpg

I put this into the ImageURL of the image control. When I look at the
properties of the image from the displayed page the URL ends up being
Devo%2520-%2520Oh,%2520No!%2520It's%2520Devo.jpg.

I am very confused ( a normal thing ) but really need a push in the right
direction here.

Thanks

Lloyd Sheen
Steve,

Thanks for the quick reply. I guess my explain is not good. I have
only the filenames in the database. The database is used to speed access to
the info rather than using the filesystem.

When I get a filename of a jpg I want to display the jpg as part of an
aspx page. I have an image control and just want to set the ImageURL
property to get it to show.

All files are under a virtual directory under IIS 7.

Lloyd Sheen

Jun 7 '07 #3

P: n/a
string imgName = imageFromDatabaseRow["image"];
ImageControl.ImageUrl =ResolveUrl("images/"+imgName);
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Lloyd Sheen" wrote:
>
"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.netwrote in
message news:7F**********************************@microsof t.com...
Here I've detailed all the steps you need to store and retrieve images in
a sql server database:
http://SteveOrr.net/articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net

"Lloyd Sheen" <a@b.cwrote in message
news:02**********************************@microsof t.com...
>I have a list of JPG's which are found in a SQL Server database. When the
page selects a certain piece of data it will refer to the file system
(resident on IIS server with a virtual directory) and files contained
within a certain folder. I have been trying for quite a while to set the
ImageURL of an image control to the correct information.

I have googled till my mind hurts but can find nothing to help. I have
even tried to copy the jpg file to a temppics folder under my site to
make that work with no luck. Just the gif showing the file does not
exist.
For example this is the filename of one of the jpgs:

D:\My Music\Classic Rock\Devo - Oh, No! It's Devo\Devo - Oh, No! It's
Devo.jpg

I put this into the ImageURL of the image control. When I look at the
properties of the image from the displayed page the URL ends up being
Devo%2520-%2520Oh,%2520No!%2520It's%2520Devo.jpg.

I am very confused ( a normal thing ) but really need a push in the right
direction here.

Thanks

Lloyd Sheen

Steve,

Thanks for the quick reply. I guess my explain is not good. I have
only the filenames in the database. The database is used to speed access to
the info rather than using the filesystem.

When I get a filename of a jpg I want to display the jpg as part of an
aspx page. I have an image control and just want to set the ImageURL
property to get it to show.

All files are under a virtual directory under IIS 7.

Lloyd Sheen
Jun 7 '07 #4

P: n/a

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:3D**********************************@microsof t.com...
string imgName = imageFromDatabaseRow["image"];
ImageControl.ImageUrl =ResolveUrl("images/"+imgName);
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Lloyd Sheen" wrote:
>>
"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.netwrote in
message news:7F**********************************@microsof t.com...
Here I've detailed all the steps you need to store and retrieve images
in
a sql server database:
http://SteveOrr.net/articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net

"Lloyd Sheen" <a@b.cwrote in message
news:02**********************************@microsof t.com...
I have a list of JPG's which are found in a SQL Server database. When
the
page selects a certain piece of data it will refer to the file system
(resident on IIS server with a virtual directory) and files contained
within a certain folder. I have been trying for quite a while to set
the
ImageURL of an image control to the correct information.

I have googled till my mind hurts but can find nothing to help. I
have
even tried to copy the jpg file to a temppics folder under my site to
make that work with no luck. Just the gif showing the file does not
exist.
For example this is the filename of one of the jpgs:

D:\My Music\Classic Rock\Devo - Oh, No! It's Devo\Devo - Oh, No! It's
Devo.jpg

I put this into the ImageURL of the image control. When I look at the
properties of the image from the displayed page the URL ends up being
Devo%2520-%2520Oh,%2520No!%2520It's%2520Devo.jpg.

I am very confused ( a normal thing ) but really need a push in the
right
direction here.

Thanks

Lloyd Sheen

Steve,

Thanks for the quick reply. I guess my explain is not good. I have
only the filenames in the database. The database is used to speed access
to
the info rather than using the filesystem.

When I get a filename of a jpg I want to display the jpg as part of
an
aspx page. I have an image control and just want to set the ImageURL
property to get it to show.

All files are under a virtual directory under IIS 7.

Lloyd Sheen
Ok here is example:

From database I get the folder name and then pickup the filename using
System.IO. The code I am using is below and then followed by the watch
values during debugging:

Dim url As String =
d.GetImageURL(Me.ListOfArtists.SelectedItem.ToStri ng,
Me.ListOfCDs.SelectedItem.ToString, Request)
Me.CDImage.ImageUrl = ResolveUrl(url)
url "D:\My Music\Best Of\Abba - The Complete
Singles Collection\Abba - The Complete Singles Collection.jpg" String
cdimage.ImageUrl "D:\My Music\Best Of\Abba - The Complete Singles
Collection\Abba - The Complete Singles Collection.jpg" String
There is no change to the url by using the ResolveURL so right now I am at a
loss. I am trying to get this to work both in Dev and for an ISS 7 hosted
site. Since I am on Vista and cannot get IIS 7 to talk to VS 2005 I need to
dev and then publish. The virtual directory that the files sit under does
not exist on the VS 2005 dev server so I am having problems resolving all of
this.

Thanks.

Lloyd Sheen

Jun 7 '07 #5

P: n/a
ok. Well, it really gets a lot easier when you create a virtual directory in
IIS that points to the images folder, wherever it may be. then the path will
always be "images/filename.ext".
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Lloyd Sheen" wrote:
>
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:3D**********************************@microsof t.com...
string imgName = imageFromDatabaseRow["image"];
ImageControl.ImageUrl =ResolveUrl("images/"+imgName);
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Lloyd Sheen" wrote:
>
"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.netwrote in
message news:7F**********************************@microsof t.com...
Here I've detailed all the steps you need to store and retrieve images
in
a sql server database:
http://SteveOrr.net/articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net

"Lloyd Sheen" <a@b.cwrote in message
news:02**********************************@microsof t.com...
I have a list of JPG's which are found in a SQL Server database. When
the
page selects a certain piece of data it will refer to the file system
(resident on IIS server with a virtual directory) and files contained
within a certain folder. I have been trying for quite a while to set
the
ImageURL of an image control to the correct information.

I have googled till my mind hurts but can find nothing to help. I
have
even tried to copy the jpg file to a temppics folder under my site to
make that work with no luck. Just the gif showing the file does not
exist.
For example this is the filename of one of the jpgs:

D:\My Music\Classic Rock\Devo - Oh, No! It's Devo\Devo - Oh, No! It's
Devo.jpg

I put this into the ImageURL of the image control. When I look at the
properties of the image from the displayed page the URL ends up being
Devo%2520-%2520Oh,%2520No!%2520It's%2520Devo.jpg.

I am very confused ( a normal thing ) but really need a push in the
right
direction here.

Thanks

Lloyd Sheen


Steve,

Thanks for the quick reply. I guess my explain is not good. I have
only the filenames in the database. The database is used to speed access
to
the info rather than using the filesystem.

When I get a filename of a jpg I want to display the jpg as part of
an
aspx page. I have an image control and just want to set the ImageURL
property to get it to show.

All files are under a virtual directory under IIS 7.

Lloyd Sheen

Ok here is example:

From database I get the folder name and then pickup the filename using
System.IO. The code I am using is below and then followed by the watch
values during debugging:

Dim url As String =
d.GetImageURL(Me.ListOfArtists.SelectedItem.ToStri ng,
Me.ListOfCDs.SelectedItem.ToString, Request)
Me.CDImage.ImageUrl = ResolveUrl(url)
url "D:\My Music\Best Of\Abba - The Complete
Singles Collection\Abba - The Complete Singles Collection.jpg" String
cdimage.ImageUrl "D:\My Music\Best Of\Abba - The Complete Singles
Collection\Abba - The Complete Singles Collection.jpg" String
There is no change to the url by using the ResolveURL so right now I am at a
loss. I am trying to get this to work both in Dev and for an ISS 7 hosted
site. Since I am on Vista and cannot get IIS 7 to talk to VS 2005 I need to
dev and then publish. The virtual directory that the files sit under does
not exist on the VS 2005 dev server so I am having problems resolving all of
this.

Thanks.

Lloyd Sheen
Jun 7 '07 #6

P: n/a

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:B2**********************************@microsof t.com...
ok. Well, it really gets a lot easier when you create a virtual directory
in
IIS that points to the images folder, wherever it may be. then the path
will
always be "images/filename.ext".
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Lloyd Sheen" wrote:
>>
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:3D**********************************@microsof t.com...
string imgName = imageFromDatabaseRow["image"];
ImageControl.ImageUrl =ResolveUrl("images/"+imgName);
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Lloyd Sheen" wrote:
"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.netwrote in
message news:7F**********************************@microsof t.com...
Here I've detailed all the steps you need to store and retrieve
images
in
a sql server database:
http://SteveOrr.net/articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net

"Lloyd Sheen" <a@b.cwrote in message
news:02**********************************@microsof t.com...
I have a list of JPG's which are found in a SQL Server database.
When
the
page selects a certain piece of data it will refer to the file
system
(resident on IIS server with a virtual directory) and files
contained
within a certain folder. I have been trying for quite a while to
set
the
ImageURL of an image control to the correct information.

I have googled till my mind hurts but can find nothing to help. I
have
even tried to copy the jpg file to a temppics folder under my site
to
make that work with no luck. Just the gif showing the file does
not
exist.
For example this is the filename of one of the jpgs:

D:\My Music\Classic Rock\Devo - Oh, No! It's Devo\Devo - Oh, No!
It's
Devo.jpg

I put this into the ImageURL of the image control. When I look at
the
properties of the image from the displayed page the URL ends up
being
Devo%2520-%2520Oh,%2520No!%2520It's%2520Devo.jpg.

I am very confused ( a normal thing ) but really need a push in the
right
direction here.

Thanks

Lloyd Sheen
Steve,

Thanks for the quick reply. I guess my explain is not good. I
have
only the filenames in the database. The database is used to speed
access
to
the info rather than using the filesystem.

When I get a filename of a jpg I want to display the jpg as part
of
an
aspx page. I have an image control and just want to set the ImageURL
property to get it to show.

All files are under a virtual directory under IIS 7.

Lloyd Sheen

Ok here is example:

From database I get the folder name and then pickup the filename using
System.IO. The code I am using is below and then followed by the watch
values during debugging:

Dim url As String =
d.GetImageURL(Me.ListOfArtists.SelectedItem.ToStr ing,
Me.ListOfCDs.SelectedItem.ToString, Request)
Me.CDImage.ImageUrl = ResolveUrl(url)
url "D:\My Music\Best Of\Abba - The Complete
Singles Collection\Abba - The Complete Singles Collection.jpg" String
cdimage.ImageUrl "D:\My Music\Best Of\Abba - The Complete Singles
Collection\Abba - The Complete Singles Collection.jpg" String
There is no change to the url by using the ResolveURL so right now I am
at a
loss. I am trying to get this to work both in Dev and for an ISS 7
hosted
site. Since I am on Vista and cannot get IIS 7 to talk to VS 2005 I need
to
dev and then publish. The virtual directory that the files sit under
does
not exist on the VS 2005 dev server so I am having problems resolving all
of
this.

Thanks.

Lloyd Sheen
Ok what I ended up doing is on the request I copy the jpg if it does not
already exist (they are not large) to a folder under my website. This in
combo with the ResolveURL gives the required result for both the dev and IIS
versions with no code change.

But this still does not answer my original question. How would I create a
URL which would point to a file which is no under my web site?

Thanks
Lloyd Sheen

Jun 8 '07 #7

P: n/a
to answer your unanswered question, a url to an image needs to be a valid
http-addressable url. It doesn't matter "where" that is, as long as it is a
web site where an <img src="http://www.wherever.com/images/yourimage.jpg" >
will work.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Lloyd Sheen" wrote:
>
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:B2**********************************@microsof t.com...
ok. Well, it really gets a lot easier when you create a virtual directory
in
IIS that points to the images folder, wherever it may be. then the path
will
always be "images/filename.ext".
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Lloyd Sheen" wrote:
>
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:3D**********************************@microsof t.com...
string imgName = imageFromDatabaseRow["image"];
ImageControl.ImageUrl =ResolveUrl("images/"+imgName);
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Lloyd Sheen" wrote:


"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.netwrote in
message news:7F**********************************@microsof t.com...
Here I've detailed all the steps you need to store and retrieve
images
in
a sql server database:
http://SteveOrr.net/articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net

"Lloyd Sheen" <a@b.cwrote in message
news:02**********************************@microsof t.com...
I have a list of JPG's which are found in a SQL Server database.
When
the
page selects a certain piece of data it will refer to the file
system
(resident on IIS server with a virtual directory) and files
contained
within a certain folder. I have been trying for quite a while to
set
the
ImageURL of an image control to the correct information.

I have googled till my mind hurts but can find nothing to help. I
have
even tried to copy the jpg file to a temppics folder under my site
to
make that work with no luck. Just the gif showing the file does
not
exist.
For example this is the filename of one of the jpgs:

D:\My Music\Classic Rock\Devo - Oh, No! It's Devo\Devo - Oh, No!
It's
Devo.jpg

I put this into the ImageURL of the image control. When I look at
the
properties of the image from the displayed page the URL ends up
being
Devo%2520-%2520Oh,%2520No!%2520It's%2520Devo.jpg.

I am very confused ( a normal thing ) but really need a push in the
right
direction here.

Thanks

Lloyd Sheen


Steve,

Thanks for the quick reply. I guess my explain is not good. I
have
only the filenames in the database. The database is used to speed
access
to
the info rather than using the filesystem.

When I get a filename of a jpg I want to display the jpg as part
of
an
aspx page. I have an image control and just want to set the ImageURL
property to get it to show.

All files are under a virtual directory under IIS 7.

Lloyd Sheen
Ok here is example:

From database I get the folder name and then pickup the filename using
System.IO. The code I am using is below and then followed by the watch
values during debugging:

Dim url As String =
d.GetImageURL(Me.ListOfArtists.SelectedItem.ToStri ng,
Me.ListOfCDs.SelectedItem.ToString, Request)
Me.CDImage.ImageUrl = ResolveUrl(url)
url "D:\My Music\Best Of\Abba - The Complete
Singles Collection\Abba - The Complete Singles Collection.jpg" String
cdimage.ImageUrl "D:\My Music\Best Of\Abba - The Complete Singles
Collection\Abba - The Complete Singles Collection.jpg" String
There is no change to the url by using the ResolveURL so right now I am
at a
loss. I am trying to get this to work both in Dev and for an ISS 7
hosted
site. Since I am on Vista and cannot get IIS 7 to talk to VS 2005 I need
to
dev and then publish. The virtual directory that the files sit under
does
not exist on the VS 2005 dev server so I am having problems resolving all
of
this.

Thanks.

Lloyd Sheen

Ok what I ended up doing is on the request I copy the jpg if it does not
already exist (they are not large) to a folder under my website. This in
combo with the ResolveURL gives the required result for both the dev and IIS
versions with no code change.

But this still does not answer my original question. How would I create a
URL which would point to a file which is no under my web site?

Thanks
Lloyd Sheen
Jun 8 '07 #8

P: n/a

Writing your own IHttpHandler is the best way to achieve image retrieving
that performs well.

Find the NorthwindImageGrabber in this demo code by Jeff Prosise

http://www.wintellect.com/Downloads/...%20ASP.NET.zip

and corresponding PictureGridView.aspx

"Lloyd Sheen" <a@b.cwrote in message
news:02**********************************@microsof t.com...
>I have a list of JPG's which are found in a SQL Server database. When the
page selects a certain piece of data it will refer to the file system
(resident on IIS server with a virtual directory) and files contained
within a certain folder. I have been trying for quite a while to set the
ImageURL of an image control to the correct information.

I have googled till my mind hurts but can find nothing to help. I have
even tried to copy the jpg file to a temppics folder under my site to make
that work with no luck. Just the gif showing the file does not exist.
For example this is the filename of one of the jpgs:

D:\My Music\Classic Rock\Devo - Oh, No! It's Devo\Devo - Oh, No! It's
Devo.jpg

I put this into the ImageURL of the image control. When I look at the
properties of the image from the displayed page the URL ends up being
Devo%2520-%2520Oh,%2520No!%2520It's%2520Devo.jpg.

I am very confused ( a normal thing ) but really need a push in the right
direction here.

Thanks

Lloyd Sheen

Jun 10 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.