i have picture in RS(2) how can i set this picture into Image1 ...??
Printable View
i have picture in RS(2) how can i set this picture into Image1 ...??
what is RS(2) ?
some what confused. but to set an image in a picturebox. in the properties u go to picture option and click on it then click on the ... to the right then it brings up the browse thing to find the picture. was that wut u were asking?
it is RECORDSET.... and 2 is index of COLUMN....Quote:
Originally Posted by dglienna
I m using IMAGE CONTROL
If the object in RS(2) is a StdPicture, then use:
Set Image1 = RS(2)
When i was trying
Set Image1.Datasource =rs <=== Type MisMatch Error
Set Image1.Datasource =rs <=== Type MisMatch Error
And now
Set Image1 =rs(2) <=== Invalid Picture Error
..?
What exactly is in RS(2)? Is it a string path, or a picture object, or something else?
I will give give logic I use but don't ask me to modify it for you - I'm sure you will figure it out how it works ;) :
VB Code:
Option Explicit Public Const MAX_PATH = 260 Public Const BLOCK_SIZE = 10000 Private Declare Function GetTempFileName Lib "kernel32" _ Alias "GetTempFileNameA" _ (ByVal lpszPath As String, ByVal lpPrefixString As String, _ ByVal wUnique As Long, ByVal lpTempFileName As String) As Long Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _ (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long Public Sub ExtractImage(rstTemp As ADODB.Recordset, sTitle As String, pctTemp As PictureBox) '============================================================================================ Dim bytes() As Byte Dim file_name As String Dim file_num As Integer Dim file_length As Long Dim num_blocks As Long Dim left_over As Long Dim block_num As Long Dim hgt As Single On Error GoTo ErrHandler 'me.imgPhoto.Visible = False Screen.MousePointer = vbHourglass DoEvents rstTemp.Find "Title='" & sTitle & "'" ' Get a temporary file name. file_name = TemporaryFileName() ' Open the file. file_num = FreeFile Open file_name For Binary As #file_num ' Copy the data into the file. file_length = rstTemp("fImageSize") num_blocks = file_length / BLOCK_SIZE left_over = file_length Mod BLOCK_SIZE 'get all chunks and write then to a temp file For block_num = 1 To num_blocks bytes() = rstTemp("fImage").GetChunk(BLOCK_SIZE) Put #file_num, , bytes() Next block_num If left_over > 0 Then bytes() = rstTemp("fImage").GetChunk(left_over) Put #file_num, , bytes() End If Close #file_num 'load image pctTemp.Picture = LoadPicture(file_name) Screen.MousePointer = vbDefault Exit Sub ErrHandler: '----------- Debug.Print Err.Description Err.Clear Resume Next End Sub Public Function TemporaryFileName() As String '============================================== Dim temp_path As String Dim temp_file As String Dim length As Long ' Get the temporary file path. temp_path = Space$(MAX_PATH) length = GetTempPath(MAX_PATH, temp_path) temp_path = Left$(temp_path, length) ' Get the file name. temp_file = Space$(MAX_PATH) GetTempFileName temp_path, "per", 0, temp_file TemporaryFileName = Left$(temp_file, InStr(temp_file, Chr$(0)) - 1) End Function
rs(2) contains PICTURE OBJECT
i have table1
fieldname =picture
this field data type = OLE Object
RhinO i appreciates your effort ...! :)Quote:
Originally Posted by vbPoet
But i think there should be some simple way of it ....
there is OLE OBJECT in rs(2)
and i want to get that picture displayed in IMAGE CONTROL ...
vbPoet, there is no "simple" way to do it. What RhinoBull posted is good and is what you need. You should take a look at it again. ;)
Quote:
Originally Posted by RobDog888
Thx Robert
if there is no simple way ;) then i consider RHINO's Code.
Anyway U & RHINO are herO ... :)
Can you tell me AT LAST y there is not any simple way of doing So ...? :ehh:
Well, there may be using a data "type" control but I never use then since they are eveil :D
If you were using ADO then I do believe its easier with the ADODC data control to bind the datasource of the image control to it.