Copy link to clipboard
Copied
I have a MS-Access database. I am working with ASP.NET. In the database there is product table in which I have "CodeNo" as a field which is a text field, and the product codes like "SM-R-2035". I also have another field "Image" which is also a text field and which have a file path in it corresponding to the particular product Image (e.g. Images\Products\SM-R-2035.jpg). So far every thing is ok. I have to update this site very frequently and lots of images are added each and every time. Its a tedious work to type the paths and file name every time and it also take a lot of time.
What I am asking is : Is it possible to get images from a specific folder at runtime which is referenced by the "code no" itself and not the file path from the database. (Say at run time the "code no" is referenced from the database and the corresponding image is loaded dynamically from the specified folder). In other word I want to avoid the tedious work of typing.
Can any one help with this issue. Any other simple suggestions are welcome.
Copy link to clipboard
Copied
Hi
Don't know if this is possible using an access database for the web, but you could use a look-up table just to prepend the file path to the image name.
See - http://www.trigonblue.com/AccessLookup.htm
Just have the file path in the access table as a separate entry and concat the file name to this, or have the file path hard coded into your html code as required.
PZ
Copy link to clipboard
Copied
Thanks pziecina !
Your suggestions are welcome I am looking forward to it. "Lookup" might not work but concatenating field values at runtime is definitely worth a try. Thanks !
Copy link to clipboard
Copied
All you need to do is simple concatenation to obtain the path for the image file. You didn't mention whether you are using VB.Net, C# or some other language to do your coding.
If the code in your database is SM-R-2035, the file name is SM-R-2035.jpg and the path to the images foilder is Images\Products\SM-R-2035.jpg, Conceptually here is what you need to do:
dim code_var
dim path_var
code_var = the code you obtain from your relevant field in the database
path_var = "Images\Products\" & code_var & ".jpg"
Now path_var is what you would call to obtain the image from your images folder.
Copy link to clipboard
Copied
Thanks Ultarsuit !
I am using VB.NET. But let me also admit that basically I am a designer and not a programmer. So writing some code for me is just like rocket science. Right now I am using Excel to concatenate the field values to get the path string and then using an "import external data" wizard in access to get that data.
You have suggested me the steps that I need to write the code in my .aspx document. I use dreamweaver's GUID by which I can place the recordset in my .aspx document visually (Just drag and drop or just click insert and dreamweaver does all coding for me)
Although I got the idea of declaring the variables and then concatenating the field values to get the string. I will definitely try and workout.
Thank you once again !
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi,
I am working on it. I am getting the string (path) correct when testing with Response.Write. But don't know to bind this path to image. Write now I am out of my office, so am not able to provide code. I will post the code in a day or two. Thank you for your kind guidance.
Copy link to clipboard
Copied
Here is my code :
<script runat="server">
Sub Page_Load( )
Dim fileName As String = Server.MapPath("Products\") & dsproducts.FieldValue("CodeNo", Nothing) & ".jpg"
<img src="<%= fileName %>" width="96" height="96" id="image" />
End Sub
</script>
When I use Response.Write(fileName) I get the correct path
i.e. D:\WebSites\Testing Project\ASPdotNet\Products\SM-R-1232.jpg
But binding it to image is not working. Can you please guide me how to get it done.
Thank you in advance.
Copy link to clipboard
Copied
Your image path doesn't conform to the requirememts of HTML The browser is not interested that the image is on D drive. It needs a proper path like http://domain.com/path/image.jpg
J.S.
http://www.ultrasuite.com/
http://twitter.com/dwUltraSuite
Copy link to clipboard
Copied
MapPath is used to obtain the physical address of a resource. You don't want to use it for this. As J.S. suggests, it's not valid for a url. Just use the doc or root relative path.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more