Ok, I think I am close to making a break through on this.
I have the following code that should, theoretically, populate an image using the file path through a sql database
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;
}
}
}
}
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.
Image ID="Image1" runat="server" Height="71px"
Width="400px" onload="Image1_Load"
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!!!
Please find below the output html.
img id="Image1" src="file:c:\online%20reporting\SQL%20Solutions\Member%20Logo\123.GIF" style="height:71px;width:400px;border-width:0px;"