Visual Basic 2010 with connection to Access with images

Asked

Viewed 63 times

0

Good morning, I am conducting a school project in Visual Basic 2010 with the link to an Access database on Football. But I want to do something more complex and include images in the players, unfortunately I have a lot of difficulty in this, the type of data I put in the Database is OLE Object In Visual Basic I have a Picturebox with an Openfiledialong with this code:

Try
  OpenFileDialog1.Title = "Abrir Imagem"
  OpenFileDialog1.FileName = "Imagens"
  OpenFileDialog1.Filter = "All Files |*.*"
  OpenFileDialog1.ShowDialog()
  ImgLigaPictureBox.Image = 
  System.Drawing.Image.FromFile(OpenFileDialog1.FileName)
        Catch ex As Exception
            'Do nothing End Try
End Try

This code allows to search the image on the computer, I wanted now that the image was saved through a querie. I don’t know if this is possible, if anyone can help.

  • 2

    Although it is possible to save images in the database, in most cases what is done is to save the file on disk and write only the path to the database. That you could do?

  • Unfortunately I don’t know

  • You want something like INSERT INTO Tabela1 (Imagem) VALUES (?) ? I can even create the code to insert images into the record, but in Access it is not recommended to do this because it records the lines sequentially making them large and misaligned, thus causing the queries to become slower and slower. For Access the best approach is to do the same as op @bfavaretto mentioned, create a column of type string and save in this column the image path.

  • Another approach is to give up Access and use an SGDB(Mysql, Oracle, Sqlserver or even Firebird) because SGDB is organized in data bales so that the image is not stored directly on the line but is referenced to a portion within the file itself( depending on the system an external file).

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.