Imports System.Data Imports System.Drawing Imports System.IO Imports Microsoft.Win32 Public Class AddGame Dim cmd As New OleDb.OleDbCommand Dim da3 As New OleDb.OleDbDataAdapter Dim result As Integer Dim imgpath As String Dim arrImage() As Byte Dim sql As String Dim fileUri As Uri Dim ds As New NEADataSet Dim da As New NEADataSetTableAdapters.GamesTableAdapter Dim dt As New NEADataSet.GamesDataTable Private Sub Bntadd_Click(sender As Object, e As RoutedEventArgs) Handles bntadd.Click Dim dr As NEADataSet.GamesRow Try Dim OFD As FileDialog = New OpenFileDialog() OFD.Filter = "Image File (*.jpg;*.bmp;*.gif;*.png)|*.jpg;*.bmp;*.gif;*.png" OFD.ShowDialog() imgpath = OFD.FileName fileUri = New Uri(OFD.FileName) OFD = Nothing Catch ex As Exception MsgBox(ex.Message.ToString()) End Try dr = dt.NewGamesRow() dr.Item("Name") = "Hello" If imgpath <> "" Then Dim img As Image = Image.FromFile(imgpath) Dim bArr As Byte() = imgToByteArray(img) dr.Item("Icon") = bArr End If dt.AddGamesRow(dr) da.Update(dt) dt.Dispose() da.Dispose() End Sub Private Function imgToByteArray(ByVal img As Image) As Byte() Using mStream As New MemoryStream() img.Save(mStream, Imaging.ImageFormat.Jpeg) Return mStream.GetBuffer() End Using End Function End Class