Hello,
I am new using vb2010 and i am working and creating a page where users can upload images with a description and be able to display it on a web page, So far the user can upload the image and decription and i am saving the information on SQL express datatabase. The table has the ID, Image Description and Image . So far that is working correctly.
I need help on displaying the image with the image description.
I am using the following code to retrieve the image, but i would like to use the HTML image control to display both of the fields.
I would like for the Image description to be on top and the image on the bottom.
Thanks for your assistance
BK
I am new using vb2010 and i am working and creating a page where users can upload images with a description and be able to display it on a web page, So far the user can upload the image and decription and i am saving the information on SQL express datatabase. The table has the ID, Image Description and Image . So far that is working correctly.
I need help on displaying the image with the image description.
I am using the following code to retrieve the image, but i would like to use the HTML image control to display both of the fields.
I would like for the Image description to be on top and the image on the bottom.
HTML Code:
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
// Create SQL Command
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "Select ImageName,Image from aspnet_cesar where ID =@ID";
cmd.CommandType = System.Data.CommandType.Text;
cmd.Connection = con;
SqlParameter ImageID = new SqlParameter("@ID", System.Data.SqlDbType.Int);
ImageID.Value = context.Request.QueryString["ID"];
cmd.Parameters.Add(ImageID);
con.Open();
SqlDataReader dReader = cmd.ExecuteReader();
dReader.Read();
if (dReader.HasRows)
{
while (dReader.Read())
{
context.Response.BinaryWrite((byte[])dReader["Image"]);
}
}
else
{
Console.WriteLine("I didn't find any relevant data.");
}
dReader.Close();
con.Close();
}
public bool IsReusable
{
get
{
return false;
}
}
}BK