Private Sub myPicture()
Dim SqlString As String = ""
Dim fs As FileStream
Dim imagedata() As Byte

fs = New FileStream(Me.PictureBox1.ImageLocation, FileMode.Open)
ReDim imagedata(fs.Length)
fs.Read(Me.imagedata, 0, fs.Length)
fs.Close()

Dim para As New List(Of SqlParameter)

SqlString = "update PartyEmpMaster set EmpImage=@img where Name='" & Me.txtEmployeeName.Text.Trim & "'"
para.Add(New SqlParameter("@img", Me.imagedata))

RasClass.addnewrecord(SqlString, para)
End Sub

Private Sub myPicture()
Dim SqlString As String = ""
Dim fs As FileStream
Dim imagedata() As Byte
dim conn As New SqlConnection(SqlConnString)
Dim command As New SqlCommand()


fs = New FileStream(Me.PictureBox1.ImageLocation, FileMode.Open)
ReDim imagedata(fs.Length)
fs.Read(Me.imagedata, 0, fs.Length)
fs.Close()

Dim cpara As New List(Of SqlParameter)

SqlString = "update PartyEmpMaster set EmpImage=@img where Name='" & Me.txtEmployeeName.Text.Trim & "'"
cpara.Add(New SqlParameter("@img", Me.imagedata))

conn.Open()
command.Connection = conn
command.CommandText = sqlstring
command.Parameters.AddRange(cpara.ToArray)
command.ExecuteNonQuery()
conn.Close()

End Sub

From Anil Sutariya

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