Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieving images using a file path stored in a sql database (nearly there!)
    text
    copied!<p>Ok, I think I am close to making a break through on this.</p> <p>I have the following code that should, theoretically, populate an image using the file path through a sql database </p> <pre><code>public void Image1_Load(object sender, EventArgs e) { ////Code to retrieve logo image from tblMemberLogo - Currently does not work!!! var connectionstring = ConfigurationManager.ConnectionStrings["PDCConnectionString"].ConnectionString; using (var cn = new SqlConnection("Data Source=STRSQL04;Initial Catalog=PDC;Integrated Security=True")) using (var cmd = cn.CreateCommand()) { cn.Open(); cmd.CommandText = "SELECT LogoFilePath FROM tblMemberlogo WHERE MemberID = '123'"; //cmd.Parameters.Add("123", "5"); using (var reader = cmd.ExecuteReader()) { if (reader.Read()) { var filepath = reader.GetString(0); Image1.ImageUrl = filepath; Label2.Text = filepath; } } } } </code></pre> <p>Now, I know I am close as the Label2 brings back the appropriate file path for Member 123. However, Image1 still possesses the dreaded red cross. The source code for this Image control is simply the following.</p> <pre><code>Image ID="Image1" runat="server" Height="71px" Width="400px" onload="Image1_Load" </code></pre> <p>I will buy whoever helps me get this over the finish one a nice big pint as I am on the verge of having (another) breakdown!!!</p> <p>Please find below the output html.</p> <p><code> img id="Image1" src="file:c:\online%20reporting\SQL%20Solutions\Member%20Logo\123.GIF" style="height:71px;width:400px;border-width:0px;" </code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload