473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to display image on webform (image control)

My image is being stored in a folder called D:\Project\Image\...jpg
Inside my Mircosoft access i made a field called ImageFile . And copy paste the image path into the field in text

Using
Expand|Select|Wrap|Line Numbers
  1. OleDbCommand sqlquery = new OleDbCommand("SELECT * FROM StudentDatabase WHERE Name ='" + TxtName.Text + "' ", ConnectionString);
  2.  OleDbDataReader reader = sqlquery.ExecuteReader();
  3.  while (reader.Read())
  4. {
  5. Image2.ImageUrl += reader[9] + "";
  6. }
  7.  
Here is my code -- which is not giving me anything
ps i am a beginner

How do i make the image appear at the Image Control Image2

How do i convert text into image?
Jan 17 '13 #1

✓ answered by Frinavale

A web browser does not understand a file path like D:\Apple\Images\111111A.gif. It only understands URLs that it can resolve to retrieve resources (like your pictures).

If your web browser cannot retrieve the image, then it cannot display the image. Therefore, you have to make the images available.

You need to create a folder called Images in your project and move the images there.

You should only need to store the image names in the database...you can then provide the correct URL to the Image control using it.

-Frinny

12 3855
Rabbit
12,516 Expert Mod 8TB
Why return all the fields in that query when all you need is the image path field? Are you sure the image path field is the tenth field in the recordset? You should check the value is actually returning what you think it's returning. You should be aware that field numbering starts at 0. Also, does it work if you hard code the path? These are some basic troubleshooting steps you should take first.
Jan 17 '13 #2
Because i doing a Personal Particular Update form with all the other details.

Reader[9] will show the image path
Jan 17 '13 #3
Rabbit
12,516 Expert Mod 8TB
How do you know that reader[9] will show the image path? Did you try the hard coding troubleshooting step?
Jan 17 '13 #4
i used the watch function when i debug and the path came out
Jan 18 '13 #5
Rabbit
12,516 Expert Mod 8TB
Why do you keep ignoring my question about the hard coding test?

What is the path that it shows?
Jan 18 '13 #6
reader[9] | "\\Images\\111111A.jpg" object {string}
Jan 18 '13 #7
Rabbit
12,516 Expert Mod 8TB
I don't know why this is the fourth time I've had to ask this. Why do you keep ignoring my question about the hard coding test?
Jan 18 '13 #8
sorry rabbit i dont think i get what u mean

Sorry if i am troubling but i think i really need your help.

D:\Apple\Images\101010A.gif << is where my picture is located.

How do i rephase it and type it into microsoft access so that when i use

Image2.ImageUrl = reader[9].ToString();

the image will appear?
Jan 21 '13 #9
Frinavale
9,735 Expert Mod 8TB
@IssueNotTissue,

There could be a number of reasons why this is not working for you.
  • As @Rabbit suggested, reader[9] may not hold the information you are looking for
  • The image may not be accessible to the browser where the image resides (the folder may not be accessible from the web)
  • The URL (path) to the image is incorrect
  • Your data is stored incorrectly


I am going to guess that the image URL is incorrect because you are storing the images in a location that is not accessible from the web. I am making that guess based on your response in post #7, you said that the path is:
\\Images\\111111A.jpg

This is not a valid URL that the web browser understands.

It should be:
  • If the image resides in a folder called Images within the root of where the page is being executed from, your URL should be one of these:
    • /Images/111111A.jpg
    • http://localhost/Images/111111A.jpg
  • If your image resides in a folder called Images located one level up from the page that it is being used in your URL (path) could be:
    • ../Images/111111A.jpg
    • http://localhost/Images/111111A.jpg

If your images are located somewhere outside of the folder that contains your web application, then you probably cannot access it from the web browser because you cannot form a valid URL to the image.

-Frinny
Jan 21 '13 #10
D:\Apple\Images\111111A.gif

i have enter in the microsoft access field a couple of path using trial & error.

using /Images/111111A.jpg i get Local/images/111111A.jpg
but using Images/111111A.jpg i get Http://Localhost/Project/Images/111111A.jpg

what should i type in the microsoft access
Jan 22 '13 #11
Frinavale
9,735 Expert Mod 8TB
A web browser does not understand a file path like D:\Apple\Images\111111A.gif. It only understands URLs that it can resolve to retrieve resources (like your pictures).

If your web browser cannot retrieve the image, then it cannot display the image. Therefore, you have to make the images available.

You need to create a folder called Images in your project and move the images there.

You should only need to store the image names in the database...you can then provide the correct URL to the Image control using it.

-Frinny
Jan 22 '13 #12
Thanks i solve it :D
Jan 28 '13 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail...
3
by: Shasta | last post by:
Using VB.NET how can I call a java Function from WebForm Button control? Any example code:? -- Tek Gurus Inc President
2
by: C CORDON | last post by:
I have an image stored in a SQL DB how can I display it in a control on a Windows Form? TIA!
2
by: rams083 | last post by:
how can i display an image on Image Control from Database, asp.net 2.0 vb? please help me... thank you for your reply...
0
by: manjitsarma | last post by:
I need to display an image in 'Image Control' of aspx page.Now the image is displayed in the aspx page itself.But I need to display it in 'Image Control'.This is a map application and the image is...
1
by: rh1200la | last post by:
Hey all. I'm trying to display a BLOB image from SQL Server to a .NET user control. I have found resources on the internet that say create a .aspx page and display at as content type image/gif. ...
5
by: faizalahmd | last post by:
How to display image in image control , which is retrieved from the data base . using c# in asp.net regards, FAIZAL AHMED.H
1
by: Myo Thura Lwin | last post by:
Hello, I am facing one problem with canvas control of Visual Editor on eclipse galileo. I would like to show the image onto canvas in fitted size. But when the image is larger than the...
2
by: santhanalakshmi | last post by:
Hi, I am running Apache and the Active Perl. In Apache, CGI folder, i had one JPEG image. I wants to display this JPEG image in my browser as the header. use CGI qw(:all); print...
0
by: anakramli | last post by:
Salam, first of all i would like to say hi all.This is my first time posting question over here. Basically im trying to make a simple product list to be display over our web project development...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.