Click here to Skip to main content
15,908,444 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a table with two fields, they are name and path of image.

While I am trying to retrieve the path from database through
oledbdatareader omgbtn.ImageUrl=dr[1].tostring();

I get an error like
"Index was outside bounds of an array"


Another problem is: How can I save changes made to imageButton?
Meaning when I open website next time the image which I set past time is not appearing?

So how can I save changes to the page to lifetime?
please please some one help me

thanks a lot in advance
Posted
Updated 21-Nov-10 22:20pm
v4
Comments
Dalek Dave 22-Nov-10 4:20am    
Edited for Grammar and REadability.

Hi Ram,

Try to use code like this:

oledbdatareader omgbtn.ImageUrl=dr["path of the image"].tostring();


This "path of the image" is the column name of your database where you are saving the image's path.

It would be nice if you can provide me the full code so that I can give you some suggestions about your second query..

Regards,
Vamsi Anil
 
Share this answer
 
v2
Comments
tulasiram3975 22-Nov-10 2:59am    
thank you for giving answer it was small mistake but you did't tell second problem now code working fine thanks anil
tulasiram3975 22-Nov-10 3:12am    
OleDbCommand cmd = new OleDbCommand("select path from images where imgname='"+TextBox3.Text+"'", con);
OleDbDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
foreach (GridViewRow myRow in GridView1.Rows)
{
ImageButton myButton = myRow.Cells[0].Controls[1] as ImageButton;
if (myButton != null)
{
myButton.ImageUrl = dr["path"].ToString();
}
}
}

this is my code and now my problem is after close the webpage and again at
the time of debugging the image what i placed in image button did't appearing
thats the main problem please save me i hope you will solve this problem
thanks in advance
Dalek Dave 22-Nov-10 4:20am    
Good Answer!
Hi,

Have you written any code for deleting the image? If yes, then you must be deleting the image.

Or just check with the path of the image while debugging, copy that and paste it in windows explorer and see whether you are directing it to the image or not.

Let me know whatz happening.

It would be nice if you can give me the paths also, both original path and the one you are getting while debugging..

Regards,
Vamsi
 
Share this answer
 

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