Hello everyone! Please Give me some guidance if u have any idea.

im doing a database using vb6 and access. im viewing my database data from access to vb using listview. each data in database have its own picture or image to display.

in the form where i put the list view, i put an image box and a command button to view the image. i only manage to found an example image viewer but not quite what i need. what i really want to do is simplify the steps to look at a data's image.

in my access dB i create a field to save the directory of the image. but i hv no idea how to open its image in vb even if i hv the directory.
how can i save the different image of different data?
how can i view the image directly on the image box when i click it on the listview?

if u hv better idea to view the image please lend me ur ideas.
u can consider my system similar to an employee management system that can save n show image of the employee.
this is the last part of my 1st dB project. i hope everyone can giv me some guidance. thanx~ :)

6 Years
Discussion Span
Last Post by tsmvasanth

# Dim CN As New ADODB.Connection
# Dim RS As ADODB.Recordset
# Dim DataFile As Integer, Fl As Long, Chunks As Integer
# Dim Fragment As Integer, Chunk() As Byte, i As Integer, FileName As String
# Private Const ChunkSize As Integer = 16384
# Private Const conChunkSize = 100
# Private Sub cmdSave_Click()
# CN.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Pubs;Data Source=Test"
# Dim strSQL As String
# strSQL = "SELECT * FROM pub_info where pub_id = '9999'"
# RS.Open strSQL, CN, adOpenForwardOnly, adLockOptimistic
# RS.AddNew
# SavePicture
# RS.Update
# Set RS = Nothing
# Set RS = New Recordset
# End Sub
# Private Sub SavePicture()
# Dim strFileNm As String
# DataFile = 1
# Open strFileNm For Binary Access Read As DataFile
# Fl = LOF(DataFile) ' Length of data in file
# If Fl = 0 Then Close DataFile: Exit Sub
# Chunks = Fl \ ChunkSize
# Fragment = Fl Mod ChunkSize
# ReDim Chunk(Fragment)
# Get DataFile, , Chunk()
# RS!logo.AppendChunk Chunk()
# ReDim Chunk(ChunkSize)
# For i = 1 To Chunks
# Get DataFile, , Chunk()
# RS!logo.AppendChunk Chunk()
# Next i
# Close DataFile
# End Sub


sub SaveImg(Path a string)
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim mystream As New ADODB.Stream
Set mystream = New ADODB.Stream

mystream.Type = adTypeBinary
rs.CursorLocation = adUseClient

rs.ActiveConnection = ConnectionString

rs.Open "SELECT id_TABLE,info,image FROM imagenes where ID_TABLA=condition" 'condition must be value that return 0 recordsets
mystream.LoadFromFile path

rs.Fields("image") = mystream.Read
rs.Fields("info") = "bmp"


This question has already been answered. Start a new discussion instead.
Take the time to help us to help you. Please be thoughtful and detailed and be sure to adhere to our posting rules.