0

I performed the following code to retrieve the path from database and show image

protected void Button2_Click(object sender, EventArgs e)
    {
        
            string t = TextBox2.Text.Trim();
            SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=D:\\Anshul\\College site\\App_Data\\afset.mdf;Integrated Security=True;User Instance=True");
            SqlCommand cmd = new SqlCommand("Select dmc from Semr Where Rollno='" + t + "'", con);
            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                string p = dr["dmc"].ToString();
                Image2.ImageUrl = p;
            }
        con.Close();
        Image2.Visible = true;
        
    }

but the image is not displayed not even the control. Please help me 1 thing i am sure it retrieves the path.

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by dnanetwork
0

i think u might be storing absolute path of image in your database
otherwise it should work..!

on debug wot is the image path did u get ... post it

0

D:\\Anshul\\CollegeSite\\Semr\\Photo.jpg
this is the path i get

I guess you can only set the relative path in ImageUrl property. not absolute path.

0

not gonna happen bro..

instead create a directory in your App

and store your images there...

in database assign that path for imageurl

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.