locked
Displaying Image from SQL Server on Mobile Web Form RRS feed

  • Question

  • User-309367553 posted

    Hi,

    I'm new to mobile web development and need some kick start on  "Displaying Image from SQL Server on Mobile Web Form".... Please help me out.

     Thanks 

     

     

    Tuesday, December 4, 2007 10:32 PM

Answers

  • User-538203642 posted

    Hi,

     I have code which retrieves the images from sql server and displays it on the mobile web form. Hope this helps.

       byte[] data = new byte[0];
      SqlConnection conn = null;
           string doxtopDbConn = ConfigurationManager.AppSettings["doxtopDbConn"];    
            try
            {
                conn = new SqlConnection(doxtopDbConn);
                conn.Open();
                SqlCommand command = new SqlCommand();
                command.Connection = conn;
                command.CommandText = string.Format("select [ATTACHMENT] FROM [HDS_FILES] where [DOC_UNID]='{0}' and [ATTACHMENT_NAME]='{1}'", docUnid, attachmentName); // for me, I have the attachment in the sql server, here im retrieving it with the given Id and attachment name.


                data = (byte[])(command.ExecuteScalar());
            }

            catch (Exception ex)
            { }
            finally
            {
                if (conn != null && conn.State != ConnectionState.Closed) conn.Close();
            }
              Response.ContentType = "image/png";
              Response.BinaryWrite(data);
              Response.Flush();
            Response.Close();

     

    Bye

    Aruna 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 7, 2007 4:59 AM