I needed to retrieve image fields on SQL Server 7.0 with VB6, and I couldn’t find any article about it. So, I assume others have had the same problem. I’ve since found a method for doing it.
You must use Microsoft ADO 2.5 and set it into the following project reference:
dim rst as new adodb.recordsetdim adoConn as new adodb.Connection
You also have to open the connection with the database.
'Open recordset....rst.Open "Select * from
where ", adoConn, adOpenKeyset,adLockOptimistic'THIS FUNCTION SAVES AN IMAGE
INTO AN IMAGE DATATYPE FIELDPrivate Function SaveImage() Dim mStream As New ADODB.Stream With mStream .Type = adTypeBinary .Open .LoadFromFile "NAME>" rst("").
Value = .Read rst.Update End With Set mStream = NothingEnd Function'THIS FUNCTION LOAD IMAGE FROM
IMAGE DATATYPE FIELD AND SAVE IT INTO AFILE.....Private Function LoadImage() Dim mStream As New ADODB.Stream With mStream .Type = adTypeBinary .Open .Write rst("") .SaveToFile "NAME>", adSaveCreateOverWrite End With Set mStream = NothingEnd Function Aside from this method, you can use a picture control to store an image,put a picture control into a form, and call it PictureTemp.
PictureTemp.DataField = "Immagine"
'Set DataField....Set PictureTemp.DataSource = rst
'Set DataSource
You can use the PictureTemp.Picture property to get your image.
Private Function LoadImage() Dim mStream As New ADODB.Stream With mStream .Type = adTypeBinary .Open PictureTemp.DataField = "Immagine"
'Set DataField.... Set PictureTemp.DataSource = rst
'Set DataSource Set MSFGRID.CellPicture = PictureTemp.Picture
'Show image into a cell ofMicrosoft FlexGrid End With Set mStream = NothingEndFunction
About Our Editorial Process
At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.
See our full editorial policy.
About Our Journalist
Charlie Frank
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience. View Author One in three Americans unsure of retirement stability
Cameron Wiggins May 3, 2024 5:39 PM Microsoft partners with OpenAI to catch up in AI race
April Isaacs May 3, 2024 5:11 PM Stock futures rise amid fluctuating market conditions
Cameron Wiggins May 3, 2024 3:57 PM Social security adjustments forecasted for 2025
April Isaacs May 3, 2024 3:10 PM Are Deceased Social Media Accounts Outnumbering the Living?
Kyle Lewis May 3, 2024 2:30 PM Alarm glitch disrupts iPhone users’ routines
Cameron Wiggins May 3, 2024 1:18 PM Google spends big to remain Apple’s default search engine
Johannah Lopez May 3, 2024 1:00 PM Social Security modifies May benefits payout plan
April Isaacs May 3, 2024 11:25 AM Yen depreciation speculated as intentional Japanese move
April Isaacs May 3, 2024 11:13 AM USD/JPY plunge sparks market speculation, Fed maintains rates
Noah Nguyen May 3, 2024 8:13 AM Social security policy changes impact retiree benefits
Rashan Dixon May 2, 2024 5:43 PM Financial anxiety rises among US adults, says AARP study
Noah Nguyen May 2, 2024 5:01 PM Game Pass refreshes library with exciting additions
Johannah Lopez May 2, 2024 3:25 PM Google’s pixel 8 pro adopts minimalistic camera finish
Johannah Lopez May 2, 2024 1:48 PM Apple’s new Beats Solo Buds offer affordable audio quality
Rashan Dixon May 2, 2024 1:23 PM Double social security payments expected certain months
April Isaacs May 2, 2024 11:57 AM Market anticipates Federal Reserve’s rate decision
Rashan Dixon May 2, 2024 11:29 AM Bitcoin remains sturdy amid crypto market turbulence
Johannah Lopez May 2, 2024 8:09 AM Binance founder sentenced to prison, steps down as CEO
Noah Nguyen May 2, 2024 7:10 AM U.S. stock futures dip, challenging market optimism
Rashan Dixon May 1, 2024 5:20 PM Inadequate information delays necessary assistance
Johannah Lopez May 1, 2024 5:15 PM June’s social security payments released early
April Isaacs May 1, 2024 3:30 PM Financial instability grows among aging Americans
Johannah Lopez May 1, 2024 3:27 PM Google improves split-screen mode for Pixel devices
Cameron Wiggins May 1, 2024 11:52 AM Apple AirPods Pro now at lowest price on Amazon
April Isaacs May 1, 2024 11:44 AM