Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 26th, 2006, 02:23 PM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retriving Binay Image From SQL Server 2000 In VB 6

i want to retrive the image from SQL server 2000 image data type and want to display the image in the picture box of visual basic 6. i have added the image in SQL server 2000 but retrving is the problem can any one help me plz............

Ammar
 
Old June 22nd, 2006, 03:09 PM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use ADO

Dim Flds As ADODB.Fields
    Dim fld As ADODB.Field
    Dim byteChunk() As Byte
    Dim strNote As String
    Dim Offset As Long
    Dim Totalsize As Long
    Dim Remainder As Long
    Dim NumOfChuncks As Long
    Dim CurrentRecPos As Long
    Dim FieldSize As Long
    Dim FileNumber As Integer
    Const HeaderSize As Long = 78
    Const ChunkSize As Long = 100
    Const TempFile As String = "tempfile.tmp"


FileNumber = FreeFile
                    Open TempFile For Binary Access Write Lock Write As FileNumber
                    Totalsize = FieldSize - HeaderSize ' Substract it from the total size.
                    byteChunk() = fld.GetChunk(HeaderSize) ' Get rid of the header.
                    NumOfChuncks = Totalsize \ ChunkSize
                    Remainder = Totalsize Mod ChunkSize
                    If Remainder > 0 Then
                        byteChunk() = fld.GetChunk(Remainder)
                        Put FileNumber, , byteChunk()
                    End If
                    Offset = Remainder
                    Do While Offset < Totalsize
                        byteChunk() = fld.GetChunk(ChunkSize)
                        Put FileNumber, , byteChunk()
                        Offset = Offset + ChunkSize
                    Loop
                    Close (FileNumber)
                    Image1.Picture = LoadPicture(TempFile)
                    Kill (TempFile)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Download in Image from Sql Server 2000 using asp surendraparashar Classic ASP Basics 0 December 16th, 2007 11:55 PM
retriving picture from database(sql) to <asp:image aspnet79434319 Classic ASP Basics 0 June 21st, 2005 01:29 AM
Saving image in SQL Server 2000 ashu_from_india ADO.NET 0 February 21st, 2005 01:10 PM
Beginning VB with SQL Server 2000 JohnAlex Pro VB Databases 2 June 29th, 2004 04:20 PM
VB Net and SQL Server 2000 hdmdev Wrox Book Feedback 1 July 22nd, 2003 04:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.