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. Database & SysAdmin
  3. Database
  4. how to insert image into sql database table

how to insert image into sql database table

Scheduled Pinned Locked Moved Database
databasehelpgraphicstutorial
5 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.
  • V Offline
    V Offline
    vrk_raju
    wrote on last edited by
    #1

    i want to insert pic into datatable pl help with vb code.. str_insert = "INSERT INTO SIS_TeachingStaff VALUES('TSMT2','V.RAJANIKANTH','LECTURER','TEACHING STAFF','Msc(Maths)','" & Emp_pic.Image & " '" '" & CByte(Me.opendialogbox.FileName.Length) & "' " cmd = New SqlCommand(str_insert, conn) cmd.Connection = conn cmd.ExecuteNonQuery() error is:operator '&' is not defined for types 'string' and 'system.drawing.image'

    C 1 Reply Last reply
    0
    • V vrk_raju

      i want to insert pic into datatable pl help with vb code.. str_insert = "INSERT INTO SIS_TeachingStaff VALUES('TSMT2','V.RAJANIKANTH','LECTURER','TEACHING STAFF','Msc(Maths)','" & Emp_pic.Image & " '" '" & CByte(Me.opendialogbox.FileName.Length) & "' " cmd = New SqlCommand(str_insert, conn) cmd.Connection = conn cmd.ExecuteNonQuery() error is:operator '&' is not defined for types 'string' and 'system.drawing.image'

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      You are injecting values into the SQL String - This is a potential security flaw in your application and you should resolve it. See SQL Injection Attacks and Tips on How to Prevent Them[^] The resoltion for the security flaw is also the resolution for your problem. You should use Parameterised queries to insert binary data.


      Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

      S 1 Reply Last reply
      0
      • C Colin Angus Mackay

        You are injecting values into the SQL String - This is a potential security flaw in your application and you should resolve it. See SQL Injection Attacks and Tips on How to Prevent Them[^] The resoltion for the security flaw is also the resolution for your problem. You should use Parameterised queries to insert binary data.


        Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

        S Offline
        S Offline
        stevehnsn
        wrote on last edited by
        #3

        Investigate using those parameterized queries to insert a byte array data source into a database field of type Blob. Definitely don't keep that first bit of code you posted though. Good luck! Steve Hanson Tasen Software
        New Hampshire (NH) Website Design and Software Development

        C 1 Reply Last reply
        0
        • S stevehnsn

          Investigate using those parameterized queries to insert a byte array data source into a database field of type Blob. Definitely don't keep that first bit of code you posted though. Good luck! Steve Hanson Tasen Software
          New Hampshire (NH) Website Design and Software Development

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          I think you meant to reply to the OP rather than me.


          Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

          S 1 Reply Last reply
          0
          • C Colin Angus Mackay

            I think you meant to reply to the OP rather than me.


            Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

            S Offline
            S Offline
            stevehnsn
            wrote on last edited by
            #5

            In fact I did. Sorry for the inconvenience. Steve Hanson Tasen Software New Hampshire Website Design & Software Development

            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