Paul

Paul

  • NA
  • 13
  • 0

Image vs Session Variables

Aug 22 2011 9:51 AM
Hello,

I would like to know how to:
- Save an image into a Session Variables
- Get the image from the Session Variable and display it on the web page.


Here's the example on how to get the image from the DB:

string v_customer_code = "PAUL";

SqlConnection v_connection = newSqlConnection(ConfigurationManager.ConnectionStrings["SqlServer"].ConnectionString))

v_connection_string = "SELECT [Photo] FROM [customers] WHERE [code] = @CODE";
SqlCommand cmd = new SqlCommand(SQL, v_connection);
cmd.Parameters.AddWithValue("@CODE", v_customer_code);

v_connection.Open();
SqlDataReader dr = cmd.ExecuteReader();

if(dr.Read())
{
Session["Customer_Photo"] = (byte[])dr["Photo"]; ????? is it correct ?????
}

dr.Close();
v_connection.Close();

Answers (1)