Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there fellow coders.
I kind of have a problem, I need to retrieve an image (an album art picture) from a Microsoft access database and display it in an image control. I can retrieve text fields from a database (Placed in a grid view control) with the following code:

lblRow1AlbumPrice1.Text = GridView1.Rows[0].Cells[8].Text;

but the Album Art is under an attachment data type, so I don’t know how or what the code will be.

this is the database within a gridview control:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource1">
<columns> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="AlbumName" HeaderText="AlbumName" SortExpression="AlbumName" />
<asp:BoundField DataField="Artist" HeaderText="Artist" SortExpression="Artist" />
<asp:BoundField DataField="ContributingArtists" HeaderText="ContributingArtists" SortExpression="ContributingArtists" />
<asp:BoundField DataField="Genre" HeaderText="Genre" SortExpression="Genre" />
<asp:BoundField DataField="Year" HeaderText="Year" SortExpression="Year" />
<asp:BoundField DataField="AmountOfStock" HeaderText="AmountOfStock" SortExpression="AmountOfStock" />
<asp:BoundField DataField="ShippingWeight" HeaderText="ShippingWeight" SortExpression="ShippingWeight" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:BoundField DataField="AlbumArt" HeaderText="AlbumArt" SortExpression="AlbumArt" />

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString6 %>" ProviderName="<%$ ConnectionStrings:ConnectionString6.ProviderName %>" SelectCommand="SELECT [ID], [AlbumName], [Artist], [ContributingArtists], [Genre], [Year], [AmountOfStock], [ShippingWeight], [Price], [AlbumArt] FROM [Music (CD)]">
Posted
Updated 1-Aug-14 3:38am
v2

Storing images in an Access database is usually a bad idea, leading to database bloat. It is much better to store the image on disk, and hold the filename and location in the database. You can then load the image from disk easily.
 
Share this answer
 
Comments
Member 10985722 1-Aug-14 12:29pm    
thanks Chris Quinn and vangapallynaveen. Chris Quinn is surprisingly easier since i have a deadline hahaha

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900