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. binding pictures to database

binding pictures to database

Scheduled Pinned Locked Moved Visual Basic
questiondatabasewpfwcftutorial
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.
  • K Offline
    K Offline
    kids17
    wrote on last edited by
    #1

    I am creating a picture gallery in which the user can scroll forward and backwards. How do I connect the pictures from my folder to the databse. What are the best controls and how to use them?

    L G 2 Replies Last reply
    0
    • K kids17

      I am creating a picture gallery in which the user can scroll forward and backwards. How do I connect the pictures from my folder to the databse. What are the best controls and how to use them?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      http://www.ammara.com/[^]

      1 Reply Last reply
      0
      • K kids17

        I am creating a picture gallery in which the user can scroll forward and backwards. How do I connect the pictures from my folder to the databse. What are the best controls and how to use them?

        G Offline
        G Offline
        Guerven
        wrote on last edited by
        #3

        you can convert an image to a stream then store it to an access database Dim ms As New MemoryStream PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat) Dim imageX() As Byte = ms.GetBuffer ms.Close() After this step you already have an image in bytes() - imageX Now.. assuming you have an access database with three fields. Message, Name, and PiC (pic is an OLE Object in access) You need to use an OledbCommand's Parameter to pass the values correctyl. here's How to Do it. oledbcommand1.Parameters.Clear() oledbcommand1.Parameters.Add(New OleDbParameter("@MESSAGE", OleDbType.WChar, 50)).Value = TextBox1.Text oledbcommand1.Parameters.Add(New OleDbParameter("@NAME", OleDbType.WChar, 50)).Value = TextBox2.Text oledbcommand1.Parameters.Add(New OleDbParameter("@PIC", OleDbType.Binary)).Value = image If VEN.Insert("INSERT INTO Table1 ( MESSAGE , NAME1 , PIC ) VALUES ( ? , ? , ? )") = 1 Then MessageBox.Show("Record Save!") Me.Close() End If ofcourse you need to setup a connection to an access database. only images added trhough this method can be retireived. to retrieve the image you need to reverse the step Dim i As Integer If IsDBNull(TABLE.Rows(ROW)(iFIELD)) Then MsgBox("You Tried to View an Image from an empty record", MsgBoxStyle.OKOnly, "Unable to Display Image") Exit Sub End If Dim arrPicture() As Byte = CType(TABLE.Rows(ROW)("PIC"),byte()) Dim ms As New MemoryStream(arrPicture) picturebox1.image = System.Drawing.Image.FromStream(ms) GUERVEN Truth or Consequence

        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