Как вставить фотографию в MS acess с помощью VB
Проблема "синтаксической ошибки в операторе INSERT into"
Что я уже пробовал:
Private Sub saveImage(sql As String) Try Dim arrImage() As Byte Dim mstream As New System.IO.MemoryStream() PictureBoxphoto.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg) arrImage = mstream.GetBuffer() Dim FileSize As UInt32 FileSize = mstream.Length mstream.Close() con.Open() cmd = New OleDbCommand With cmd .Connection = con .CommandText = sql .Parameters.AddWithValue("@img", arrImage) .ExecuteNonQuery() End With Catch ex As Exception MsgBox(ex.Message) Finally con.Close() End Try End Sub
Private Sub btnsavephoto_Click(sender As Object, e As EventArgs) Handles btnsavephoto.Click sql = "Insert into image(ID,img) Values('" & TextBoxpassport.Text & "',@img)" saveImage(sql) MsgBox("Image has been saved in the database") End Sub