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. :)