none
displaying images in an access database

    Question

  • Using Access Data Source, and gridview, I am displaying several fields(columns) of data from my access data base.  Now I have added an image field in my access data base with images embedded.  Now when I try and configure my access data source , from my access data base, if never displays the image field.  Another words it does not let me select it.  So I guess I have to add some sort of image control, if this is the case, I would have an access data source, and an access image control, or something like that.  In this scenario, would I need one, or two gridviews

    Rusty Dils

    Friday, July 13, 2012 4:04 PM

Answers

  • If you want to display a gridview with images in one of the fields, get the file name from the database, and use it in an ImageField in the gridview.  One page, no image selection.

    An example is here: http://msdn.microsoft.com/en-us/library/aa479350.aspx  (You'd use your own datasource.)

    You can do similar things with more flexible formatting in a ListView, where you put an image control in the template and evaluate the file name from the database as the image's source.  You'd end up with something like:

    <asp:Image id="pictureControlID"

    runat="server" AlternateText='<% #Eval("pictureName") %>'

    ImageUrl='<%# "~/photos/" + Eval("pictureFile") %>' />

    This assumes your image files are in ~/photos/ and your database had the filename in it under "pictureFile", and a name/description for the picture in "pictureName".
    • Marked as answer by DilsRusty Thursday, August 23, 2012 8:44 PM
    Monday, July 30, 2012 10:49 PM

All replies

  • Retrieving embedded images in a database for display in a webpage is complex, and not something you'd ask here.  (No, an image control won't do it - that's for referencing image files, not converting binary from your database.)  You'd need to ask on the asp.net forum or google for the code.

    (Here's an example using an SQL server database; you'd need to find corresponding information for an Access database: http://odetocode.com/articles/172.aspx )

    Far easier:   Put the images files themselves in your site, and put the location and names of the files in your database.  Then you can use an image control to reference the file name you get from your database.  This also saves database space: the file name is smaller than the image binary.

    Friday, July 13, 2012 4:46 PM
  • Another example of showing images from a database link is tutorial number 6:

    http://www.homepagedoctor.com/Tutorials.aspx



    ClarkNK, A.K.A. HomePage Doctor
    HomePageDoctor.com -- Expression Web database tutorials
    Ownertrades.com -- Created with Expression, VWDExress, SQL Express, and ASP.NET
    Arvixe -- My favored web host
    Friday, July 13, 2012 6:09 PM
  • Clark NK, thanks for this answer.  I am going to try to do this from your tutorial 6.  Can you recommend a couple of modifications.  Instead of two pictures, I only want one picture.

    Second, and very important,  I don't want the picture to need selecting, when the several records of the data base are displayed in the browser, I just want the pictures to be retrieved and show up automatically. 

    Can you recommend modifications to tutorial 6 for this to happen, thanks, Rusty


    Rusty Dils

    Monday, July 30, 2012 9:55 PM
  • If you want to display a gridview with images in one of the fields, get the file name from the database, and use it in an ImageField in the gridview.  One page, no image selection.

    An example is here: http://msdn.microsoft.com/en-us/library/aa479350.aspx  (You'd use your own datasource.)

    You can do similar things with more flexible formatting in a ListView, where you put an image control in the template and evaluate the file name from the database as the image's source.  You'd end up with something like:

    <asp:Image id="pictureControlID"

    runat="server" AlternateText='<% #Eval("pictureName") %>'

    ImageUrl='<%# "~/photos/" + Eval("pictureFile") %>' />

    This assumes your image files are in ~/photos/ and your database had the filename in it under "pictureFile", and a name/description for the picture in "pictureName".
    • Marked as answer by DilsRusty Thursday, August 23, 2012 8:44 PM
    Monday, July 30, 2012 10:49 PM
  • Hi Clark, this is Rusty Dils.  I am finishing up your tutorial # 6.  It ALMOST works.  Instead of the picture showing up, I am getting a red X.

    I have done the following to try and resolve.

    1.  Explorer tools, internet options, multimedia, make sure show pictures box is checked.  It was.

    2.  Right click on the x, and look a properties.  it does seem to be a ".jpg" file.

         http://localhost:46090/images/images/item4front.jpg

    3.  I increased the padding on the cells in my picture table, thinking the picture just was not fitting, that did not help either.

    Do you have any suggestions


    Rusty Dils

    Sunday, August 12, 2012 4:15 PM
  • That source path looks a little funky:

    http://localhost:46090/images/images/item4front.jpg

    Do you really have an images folder inside an images folder? The red x box you're seeing means that the referenced image cannot be found, which would be the case if your path to the image was in error, as it seems. It has nothing to do with your browser settings or the size of the display element.

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    Sunday, August 12, 2012 6:10 PM
  • Thanks Kathy, I got it working.  Just used grid control, then I just added an image column, that linked to the same access database.  It linked to a field in the access database with the url's to the pictures.  As usual, I had trouble with paths, but once I figured that out it works.

    Now what I am struggling with is probably not for this forumn, but here goes anyway.

    I have added some sample pictures, and as I previously explained, when I go to preview in browser it works fine.  However, when I actually go to my website and try it, it brings up an old page with just some of the pictures working, before all of the problems were solved.  I don't know what to do about this.  I have tried clearing browser history, I have tried four or five other browsers, I even tried deleting the link, but no matter what I do, when I actually go to my website it brings up the old messed up page.  But again, when I preview in browser, it looks correct. The only thing I have not tried as far as clearing browser history goes is a stick of dynamite. Does anyone have any suggestions on how to fix this problem with my gridview, aspx page history.

    Thanks, Rusty


    Rusty Dils

    Thursday, August 23, 2012 8:51 PM
  • Well, first, give us a link to that page and tell us what is different between the old page and the new page.  In other words, the first thing to answer is if it has anything to do with browser history.  Let us tell you which page we see.
    Thursday, August 23, 2012 9:10 PM
  • ok, here are the links

    http://localhost:46602/Investors/newcountiesonly.aspx?County=Sandoval

    This link is from my preview in browser page, I have to actually type in the ?County=Sandoval

    In this preview in browser page there are five pictures of houses in the far right column.

    That is how it is supposed to look.  All five of the house pictures are approximately the same size

    http://140.174.68.114/Investors/newcountiesonly.aspx?County=Sandoval

    This is the actual website link.

    On my computer, and on my smart phone, this link shows an old messed up page.

    On the far right column I can only see two houses, and the pictures are of quite different sizes. This is atleast what I get on my computer(no matter the browser), and on my smart phone


    Rusty Dils

    Thursday, August 23, 2012 9:30 PM
  • Rather obviously a link on your PC is not what we need.  We can't see it.  :)   We have to go by your description of it.

    As for the hosted link, the only "messed up" I see are the missing pictures, since I don't know else you expect to see.

    The answer for them is simple: you didn't publish the missing pictures, or you didn't publish them where you are telling the page to find them.  Publish the pictures, or correct the links.

    Are you pointing to pictures *inside* your local site, and thus inside your published site?  Some of the image locations in the published source code are walking up several levels of directory.

    Thursday, August 23, 2012 9:43 PM
  • What I am trying to say, is I have fixed the problem.  Yes, I did not have them published in the correct spot, hence, the missing pictures.  However, a week or so ago I moved the pictures to the correct spot, and now, IN PREVIEW IN BROWSER WHICH I KNOW YOU CAN'T SEE.  The pictures show up correctly.  I see all five pictures, all the same size.  It seems as though I have fixed the problem according to preview in browser.  However, as I previously said, no matter how many different browsers I use, or how many browser histories I clear, I still get the messed up page (meaning only showing two pictures).  This is what I don't undertstand, how can preview in browser show me what I am wanting to see, Yet my actual website seems to show an old version.  I even disconnected the link so that their is no way my site could show anything, but it still shows the old page.  Is their a microsoft forum for explorer, But I think it is more than explorer, I think it is somehow saved in Windows history, even though I have deleted all temporary internet files, deleted all browser history, It still ends up showing this old version of my aspx page.  What I am wondering from you guys, is  possible explanations as to why it works in preview in browser, but not on actual site.  Is there any other explanation besides browser history.


    Rusty Dils

    Thursday, August 23, 2012 10:22 PM
  • Preview shows you your local page.  Browsers looking at the hosted site show you what you published.  The images are not where they are told to be on the published site, as I said.  It has nothing to do with browser history: I never went to that page before and see the incorrect page; I have no prior browser history. The correct page and properly located pictures with correct files and links in the database and gridview is NOT published, or not published to the correct location.  Publish ALL your changes, if the local site works.


    (Adding: is there a reason you are using an IP address URL rather than the domain name?)

    • Edited by KathyW2 Friday, August 24, 2012 12:01 AM
    Thursday, August 23, 2012 10:56 PM
  • ok, That is the answer I was looking for.  thank you very much.  I will work on that. 

    As far as the IP address instead of the Domain name, I just don't want to publish it to the domain name until I am finished, or almost finished.

    Thanks for everything.  I will try and see what I am doing wrong.  Thanks


    Rusty Dils

    Friday, August 24, 2012 12:02 AM
  •   ok, That is the answer I was looking for.  thank you very much.  I will work on that. 

    As far as the IP address instead of the Domain name, I just don't want to publish it to the domain name until I am finished, or almost finished.

    Thanks for everything.  I will try and see what I am doing wrong.  Thanks

    FWIW, I see the same thing that you and Kathy see when I visit that link, and I have zero history stored for that site, so it is not an issue of caching at all. What you see there is what you have published.

    EW presumes that the folder you are using for your local site root has a one-to-one correspondence with the remote site root when it publishes. If that is not the case, if the folder you are publishing to on the remote server is not actually the site root, but is one level lower, or higher (unlikely, since most providers prohibit that), none of your relative paths will be correct.

    The provider determines which folder is considered to be the site root. On Windows servers that I have used, I have seen both "httpdocs" and "www," and I'm sure there are others (for local IIS, for example, the default is "C:\inetpub\wwwroot\"). On Linux/Apache, it's usually "public_html." Oh, and at least one provider I have used has no designated folder—the FTP address provided goes straight to the site root, so "Directory" is left blank.

    The point is, if you are not publishing to the correct site root folder for the remote site, your changes are going into a never-never land, and you will never see them on the live site.

    To set the folder to publish to, select "Site View|Publishing|Publishing Settings." In the dialog that appears, set the correct folder to publish to in the "Directory" field, like so:

    Whenever you use any of the "Publish..." commands, the folder you are using as the site root in EW will be published to that target folder, and all subordinate folders as well, maintaining your relative paths. If you don't know for sure what your target folder is supposed to be, call your provider, or look in their FAQs; it's probably there. 

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    Friday, August 24, 2012 1:17 AM
  • Ok Paladyn and Kathy, this seems to have solved my problem.  I was not fully understanding about saving, publishing changed files, and publishing entire site.  Depending on the changes I make with pictures and Access Database, and Grid View, To get everything to work I have to publish entire site.  I am fine with that.  It works Now.  Now in the words of Columbo, Just one more thing.

    It occurred to me yesterday that the way I am working with pictures may not be quite right.  I am doing a save as on my pictures, then I resize them to 139 pixcels wide, and everything is hunky dory.  However, It occurs to me yesterday, that before I do this with mass quantities of pictures, I am probably not doing this right.  The problem with the way I am doing it, is that size of that picture becomes permanent, and you cannot click on it to get a bigger size , .  So last night, I thought, I just need to set them up with thumbnails, I don't have much experience with this though.  So today I tried, but I can't seem to make it happen.  I guess thumbnails are just for when you actually place the picture on a page.  I thought I could go into my pictures folder, select a fullsize picture,(one that I have not resized to 139 pixels yet) and auto thumbnail it.  But the auto thumbnail feature does not hightlight, unless I insert the picture onto a page.  I know other people are doing this.  Anybody have any suggestions.  Refreshing memory, right now I use an image field in Grid View Control to get the url from an accessdatabase field of the actual picture located in a folder.  Cannot figure out how to thumbnail.

    Any suggestions would be appreciated


    Rusty Dils

    Sunday, September 16, 2012 2:14 PM
  • Your question doesn't make any sense as stated. You say...

    I am doing a save as on my pictures, then I resize them to 139 pixcels wide

    Hunh...? If you are saving the images, then how are you resizing them? In the browser? Bad idea.

    Then you say...

    But the auto thumbnail feature does not hightlight, unless I insert the picture onto a page.

    ??? What does that mean? First, what do you mean by "highlight?" Second, nothing highlights, whatever that means, unless it is visible on the page. What are you talking about?

    Where do you want the thumbnails to appear? Post a link to the page that you're talking about. Describe exactly what is happening now that you want to change. Describe exactly what you would like to have happen.

    Your question is ay to unclear for anyone to make sense of. We cannot see either your process or the page. Reread your post from the point of view of someone who is not sitting in your chair and you will see what I mean.

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    Sunday, September 16, 2012 6:08 PM
  • Autothumbnail has nothing to do with clicking on a gridview image to get a larger image, which is what I'm guessing you are trying to do.  And, for quality, don't use EW (or a browser) to resize images: use a graphics program to create both sizes of the image.

    You would have to create both images, and save them in your site separately.  If you put the thumbnails in one directory and the full sized ones in another, with the same file names, you could use the same image file name to construct both image references, with just a different directory used on the gridview page from the one used on the full sized page. You'd need to program a link attached to that gridview image, or in the same grid, to go a page displaying the larger image.  You could set it up for one page to pull the image from a query string parameter in the link to that page, with the image name, to get the right picture.

    This isn't an EW-does-it-for-you thing.  You'd need to dig deeper into asp.net.

    Sunday, September 16, 2012 10:29 PM
  • ok Kathy, I will work on it. thanks

    Rusty Dils

    Monday, September 17, 2012 1:29 PM