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. General Programming
  3. Visual Basic
  4. Saving an image into a database from a dataset

Saving an image into a database from a dataset

Scheduled Pinned Locked Moved Visual Basic
databasehelp
3 Posts 3 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.
  • R Offline
    R Offline
    Regardt
    wrote on last edited by
    #1

    I already build a table inside a dataset. The rows of the table consist of basic varchar and integer columns accept for a binary column.(My image problem) I want to write the rows as whole into the my sql database from the dataset. I would really appreciate it if any can help me with this problem. If possible I would like to use a stored procedure to solve this problem Regardt

    M 1 Reply Last reply
    0
    • R Regardt

      I already build a table inside a dataset. The rows of the table consist of basic varchar and integer columns accept for a binary column.(My image problem) I want to write the rows as whole into the my sql database from the dataset. I would really appreciate it if any can help me with this problem. If possible I would like to use a stored procedure to solve this problem Regardt

      M Offline
      M Offline
      Matt Casto
      wrote on last edited by
      #2

      I ran into a problem inserting/updating images through a stored procedure, I think because of a limit to the size of data sent through a stored procedure parameter. To solve this problem, I execute inserts and updates directly, like this: Public Function Insert(ByVal imageData As Byte(), ByVal imageType As String) As Integer Dim cmdText As String = "INSERT INTO MyImages(Image, ImageType) VALUES(@image, @imageType) SELECT SCOPE_IDENTITY()" Dim args(1) As SqlParameter args(0) = New SqlParameter("@image", imageData) args(1) = New SqlParameter("@imageType", imageType) Try Return CInt(SqlHelper.ExecuteScalar(ConnectionString, CommandType.Text, cmdText, args)) Catch ex As SqlException ' do error handling Throw End Try End Function NOTE: I'm using the Microsoft Data Access Application Block[^] (SqlHelper) for data access.

      R 1 Reply Last reply
      0
      • M Matt Casto

        I ran into a problem inserting/updating images through a stored procedure, I think because of a limit to the size of data sent through a stored procedure parameter. To solve this problem, I execute inserts and updates directly, like this: Public Function Insert(ByVal imageData As Byte(), ByVal imageType As String) As Integer Dim cmdText As String = "INSERT INTO MyImages(Image, ImageType) VALUES(@image, @imageType) SELECT SCOPE_IDENTITY()" Dim args(1) As SqlParameter args(0) = New SqlParameter("@image", imageData) args(1) = New SqlParameter("@imageType", imageType) Try Return CInt(SqlHelper.ExecuteScalar(ConnectionString, CommandType.Text, cmdText, args)) Catch ex As SqlException ' do error handling Throw End Try End Function NOTE: I'm using the Microsoft Data Access Application Block[^] (SqlHelper) for data access.

        R Offline
        R Offline
        RZLR
        wrote on last edited by
        #3

        I had the same problem with the stored proc & Oracle. You will have to do the insert directly, or use a SP to create the entry without the image data & then update the record with the image data.

        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