Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. displayin image

displayin image

Scheduled Pinned Locked Moved ASP.NET
databasecsharphtmlmysqlsysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    boyindie
    wrote on last edited by
    #1

    Hi I am tryin to display an image which is stored in a database i ahve a procedure which will go to the appropiate record in my database and pull the file name from it it should then take the file name and put it into a prefixed img src tag, which should then take the appropiate file from the imagestore and display to the web page it all seems to work fine, even when i check the html source file the tag has been filled with the valid address but it jus doesn't seem to want to render the image Is there anythin i need to do here? here is my code Sub getimage(ByVal sender As Object, ByVal e As EventArgs) 'Create connection string to pass database, string holds login information to mySQL, Dim connectionString As String connectionString = "Server=localhost; u;database=ftp1;" 'Builds .net mysql connection and passes connection string into method Dim connection As New MySqlConnection(connectionString) 'Create mySql command string for passing query or SPROC(Stored Procedure) Dim cmdString As New MySqlCommand 'Set Command to equal mySql connection,t so can pass SQL query cmdString.Connection = connection 'Set command string to equal SPROC cmdString.CommandText = "sp_getImage" 'ONLY PLACE THIS IF SPROC, sets the command to a SPROC cmdString.CommandType = CommandType.StoredProcedure Dim literr As New LiteralControl Dim param As MySqlParameter Try 'Creates parameter which will be passed into procedure param = cmdString.Parameters.Add("?p_id", MySqlDbType.Int32) 'Sets parameter type equal to input param.Direction = ParameterDirection.Input 'Sets parameter value equal to value held in textbox param.Value = 4 'Creates parameter to pass into SPROC param = cmdString.Parameters.Add("?p_image", MySqlDbType.VarChar) 'Sets parameter type to output cmdString.Parameters("?p_image").Direction = ParameterDirection.Output connection.Open() 'Opens DB connection cmdString.ExecuteNonQuery() 'Executes procedure and reads in OUTPUT parameter connection.Close() 'Closes DB connection Catch ex As Exception literr.Text = ex.Message MsgBox(ex.Message) End Try MsgBox(cmdString.Parameters("?p_image").Value) Dim imageStore As Strin

    F 1 Reply Last reply
    0
    • B boyindie

      Hi I am tryin to display an image which is stored in a database i ahve a procedure which will go to the appropiate record in my database and pull the file name from it it should then take the file name and put it into a prefixed img src tag, which should then take the appropiate file from the imagestore and display to the web page it all seems to work fine, even when i check the html source file the tag has been filled with the valid address but it jus doesn't seem to want to render the image Is there anythin i need to do here? here is my code Sub getimage(ByVal sender As Object, ByVal e As EventArgs) 'Create connection string to pass database, string holds login information to mySQL, Dim connectionString As String connectionString = "Server=localhost; u;database=ftp1;" 'Builds .net mysql connection and passes connection string into method Dim connection As New MySqlConnection(connectionString) 'Create mySql command string for passing query or SPROC(Stored Procedure) Dim cmdString As New MySqlCommand 'Set Command to equal mySql connection,t so can pass SQL query cmdString.Connection = connection 'Set command string to equal SPROC cmdString.CommandText = "sp_getImage" 'ONLY PLACE THIS IF SPROC, sets the command to a SPROC cmdString.CommandType = CommandType.StoredProcedure Dim literr As New LiteralControl Dim param As MySqlParameter Try 'Creates parameter which will be passed into procedure param = cmdString.Parameters.Add("?p_id", MySqlDbType.Int32) 'Sets parameter type equal to input param.Direction = ParameterDirection.Input 'Sets parameter value equal to value held in textbox param.Value = 4 'Creates parameter to pass into SPROC param = cmdString.Parameters.Add("?p_image", MySqlDbType.VarChar) 'Sets parameter type to output cmdString.Parameters("?p_image").Direction = ParameterDirection.Output connection.Open() 'Opens DB connection cmdString.ExecuteNonQuery() 'Executes procedure and reads in OUTPUT parameter connection.Close() 'Closes DB connection Catch ex As Exception literr.Text = ex.Message MsgBox(ex.Message) End Try MsgBox(cmdString.Parameters("?p_image").Value) Dim imageStore As Strin

      F Offline
      F Offline
      Fred_Smith
      wrote on last edited by
      #2

      boyindie wrote:

      when i check the html source file the tag has been filled with the valid address but it jus doesn't seem to want to render the image

      You need to set teh ImageUrl to either a relative path from where the webpage is, or else a fully qualified web-address (http://www...etc). It can't just be any folder on your hard drive. If your page is in the root folder of your website, adn the images in a subfo9lder called "images", you could set imgHolder.ImageUrl = ("images/" & imageStore) Your images folder (test) needs to be within your web application.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups