this is the code i have added to save image:
Public Sub LoadPhoto(ByVal slno As String)
Dim str As String = "SELECT Photo FROM TblImage WHERE STAFFID = '" & slno & "'"
connect2data.Open()
Dim cmd As New OleDb.OleDbCommand(str, connect2data)
Dim b() As Byte
b = cmd.ExecuteScalar()
connect2data.Close()
If (b.Length > 0) Then
Dim stream As New MemoryStream(b, True)
stream.Write(b, 0, b.Length)
DrawToScale(New Bitmap(stream))
stream.Close()
End If
End Sub
This is the code to insert image:
Private Sub SaveImg()
Dim br As New IO.BinaryReader(New IO.FileStream(TxtPhto.Text, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read))
Dim arr() As Byte = br.ReadBytes(br.BaseStream.Length)
Dim cmd As OleDbCommand
Dim sql As String
connect2data = Connectionprocess()
connect2data.Open()
sql = "INSERT INTO TblImage VALUES('" & TxtSID.Text & "','" & arr(arr.Length - 1) & "')"
cmd = New OleDbCommand(sql, connect2data)
cmd.ExecuteNonQuery()
connect2data.Close()
End Sub
But while retreiving the image i am getting the msg Parameter is not valid..Please chk this code
its urgent..
- Add new comment
- 40 views