hi there, can anyone please help me how to insert, search and delete a picture in vb.net and Microsoft access 2007? A picture that will be store in access is inserted in a form or a picture box. But it seems i have the wrong codes.. and when i click the insert button, it doesn't store in the access, and when i click the search button, nothing appear in the picture box. please help me.. thanks god bless

here's my code for insert.

Dim konek As New OleDbConnection
konek.ConnectionString = strConnection
Dim sqlInsert As String = ""
sqlInsert = "INSERT INTO Table1" _
& "(Picture )" _
& " VALUES " _
& "(@Picture)"

Dim komand As New OleDbCommand
komand.Connection = konek
komand.CommandText = sqlInsert
komand.CommandType = CommandType.Text
komand.Parameters.AddWithValue("@Picture", Me.Picture_box1.Text)


konek.Open()
komand.ExecuteNonQuery()
konek.Close()

MsgBox("New Picture Was Inserted")


- and here's my code for search.


Dim konek As New OleDbConnection
konek.ConnectionString = strConnection

Dim SqlSelect As String = ""
SqlSelect = "Select * FROM Table1 Where Picture = @Picture"
Dim komand As New OleDbCommand

komand.Connection = konek
komand.CommandText = SqlSelect
komand.CommandType = CommandType.Text

komand.Parameters.AddWithValue("@Picture", Me.Picture_box1.Text)

konek.Open()
Dim reader As OleDbDataReader
reader = komand.ExecuteReader()


If reader.Read Then
MsgBox("Picture Found")
Me.Picture_box1.Text = reader("Picture") & ""


Else
MsgBox("Not Found")
Me.Picture_box1.Text = ""

End If
konek.Close()

thanks for the replies and i know u guys will help me. :)

From your code i am not sure what are you inserting into the picture field ?

Since you are using Me.Picture_box1.Text, i do not understand how that will store the picture in database.

so sir what code should i use? i am having trouble finishing this project.. please help! tnx

I'm really not sure since I do not bother w/db programming yet, although see if this helps.
.That thread link, saves an image to a .txt file and reads it back. Could be possibly done the same w/db, not just a TEMP .txt file, although not sure. Good luck.

This article has been dead for over six months. Start a new discussion instead.