To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier

Reply Post New Thread
 
Thread Tools Display Modes
Old Apr 20th, 2005, 07:29 PM   #1
vbPoet
Fanatic Member
 
vbPoet's Avatar
 
Join Date: Feb 05
Location: Searching ..
Posts: 669
vbPoet is on a distinguished road (10+)
Resolved [Resolved] Picture in ACCESS

how can picture file can be stored in Access Database...

** Don't advice me
i) to store path of file
ii) it increases OHD
iii) Bla Blah ...!!!!

Last edited by vbPoet; Apr 20th, 2005 at 08:53 PM.
vbPoet is offline   Reply With Quote
Old Apr 20th, 2005, 07:44 PM   #2
RhinoBull
PowerPoster
 
RhinoBull's Avatar
 
Join Date: Mar 04
Location: New Amsterdam
Posts: 21,118
RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)
Re: Picture in ACCESS

Here is a sample procedure to store image:
VB Code:
  1. Public Sub AddNewImage(rstTemp As ADODB.Recordset, _
  2.                        sTitle As String, sFileName As String)
  3. '=============================================================
  4. Dim file_num As String
  5. Dim file_length As Long
  6. Dim bytes() As Byte
  7. Dim num_blocks As Long
  8. Dim left_over As Long
  9. Dim block_num As Long
  10. On Error GoTo ErrHandler
  11.     rstTemp.Find "Title='" & sTitle & "'"
  12.    
  13.     file_num = FreeFile
  14.     Open sFileName For Binary Access Read As #file_num
  15.    
  16.     file_length = LOF(file_num)
  17.    
  18.     If file_length > 0 Then
  19.         num_blocks = file_length / BLOCK_SIZE
  20.         left_over = file_length Mod BLOCK_SIZE
  21.        
  22.         rstTemp("fImageSize") = file_length
  23.        
  24.         ReDim bytes(BLOCK_SIZE)
  25.         For block_num = 1 To num_blocks
  26.             Get #file_num, , bytes()
  27.             rstTemp("fImage").AppendChunk bytes()
  28.         Next block_num
  29.        
  30.         If left_over > 0 Then
  31.             ReDim bytes(left_over)
  32.             Get #file_num, , bytes()
  33.             rstTemp("fImage").AppendChunk bytes()
  34.         End If
  35.        
  36.         Close #file_num
  37.     End If
  38.    
  39.     rstTemp.Update
  40.    
  41.     Exit Sub
  42. ErrHandler:
  43.     Debug.Print Err.Description
  44.     Err.Clear
  45.     'Resume Next
  46.     Exit Sub
  47. End Sub
But KIM that storing PATH is a better approach, though.
RhinoBull is offline   Reply With Quote
Old Apr 20th, 2005, 07:47 PM   #3
dee-u
Software Carpenter
 
dee-u's Avatar
 
Join Date: Feb 05
Location: Philippines
Posts: 9,747
dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)
Re: Picture in ACCESS

dee-u is offline   Reply With Quote
Old Apr 20th, 2005, 07:49 PM   #4
vbPoet
Fanatic Member
 
vbPoet's Avatar
 
Join Date: Feb 05
Location: Searching ..
Posts: 669
vbPoet is on a distinguished road (10+)
Re: Picture in ACCESS

thx RhinO.
from your code snippet i realise that .. with your same code any file can be stored in database like .exe,.jpg,.swf,.doc
because you are first gaining binary access then appending this chunk into database ...
M i right ..?
vbPoet is offline   Reply With Quote
Old Apr 20th, 2005, 07:54 PM   #5
RhinoBull
PowerPoster
 
RhinoBull's Avatar
 
Join Date: Mar 04
Location: New Amsterdam
Posts: 21,118
RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)
Re: Picture in ACCESS

Absolutely yes!
The only problem is that MS Access is limited to 2GB ... but realistically after databse file reaches 1GB you will notice performance issues so frequently compacting mdb is highly preferable.
RhinoBull is offline   Reply With Quote
Old Apr 20th, 2005, 08:01 PM   #6
vbPoet
Fanatic Member
 
vbPoet's Avatar
 
Join Date: Feb 05
Location: Searching ..
Posts: 669
vbPoet is on a distinguished road (10+)
Re: Picture in ACCESS

Quote:
Originally Posted by RhinoBull
Absolutely yes!
The only problem is that MS Access is limited to 2GB ... but realistically after databse file reaches 1GB you will notice performance issues so frequently compacting mdb is highly preferable.

thx deU & RhinO
it means RhinO if we are using Oracle,mySQL then no Problem ..
vbPoet is offline   Reply With Quote
Old Apr 20th, 2005, 08:52 PM   #8
vbPoet
Fanatic Member
 
vbPoet's Avatar
 
Join Date: Feb 05
Location: Searching ..
Posts: 669
vbPoet is on a distinguished road (10+)
Re: Picture in ACCESS

thx RhinO
but unfortunately i cannot rate your post
it says
Spread your post any other place ( some thing like that )
vbPoet is offline   Reply With Quote
Old Apr 20th, 2005, 09:05 PM   #10
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,875
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: [Resolved] Picture in ACCESS

Hey RB, what is BLOCK_SIZE defined as? Nice code btw
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Apr 20th, 2005, 10:11 PM   #12
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,875
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: [Resolved] Picture in ACCESS

Oh, its a user defined const. Thanks.
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Apr 21st, 2005, 07:13 PM   #14
dee-u
Software Carpenter
 
dee-u's Avatar
 
Join Date: Feb 05
Location: Philippines
Posts: 9,747
dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)dee-u is a splendid one to behold (700+)
Re: [Resolved] Picture in ACCESS

This might have some importance with you....
Quote:
thx RhinO
but unfortunately i cannot rate your post
it says
Spread your post any other place ( some thing like that )
Why dont give me that rate instead?
dee-u is offline   Reply With Quote
Old Apr 11th, 2006, 07:48 PM   #15
Krass
Hyperactive Member
 
Krass's Avatar
 
Join Date: Aug 00
Location: Montreal
Posts: 442
Krass is on a distinguished road (10+)
Re: [Resolved] Picture in ACCESS

RhinoBull, since you seem to be a guru in that field, my question is primarily aimed at you .......

I have a PictureBox filled with random colored pixels.

SavePicture pic1.Image, "c:\test\test.bmp" worked great. So I can now save test.bmp into a database. But what if I wanted to skip that step, and save the PictureBox *DIRECTLY* into my database... Can that be done?

I would appreciate to avoid saving the picture to disk first.

Thanks
__________________
Christian (Email/MSN: krass_methot@hotmail.com)
Krass is offline   Reply With Quote
Old Apr 11th, 2006, 08:47 PM   #16
RhinoBull
PowerPoster
 
RhinoBull's Avatar
 
Join Date: Mar 04
Location: New Amsterdam
Posts: 21,118
RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)
Re: [Resolved] Picture in ACCESS

Quote:
Originally Posted by Krass
...I would appreciate to avoid saving the picture to disk first...
Why? What's the problem with that? You save it to disk, then to your database and then delete the file if you wish not to keep it...
RhinoBull is offline   Reply With Quote
Old May 20th, 2006, 02:25 AM   #17
Krass
Hyperactive Member
 
Krass's Avatar
 
Join Date: Aug 00
Location: Montreal
Posts: 442
Krass is on a distinguished road (10+)
Re: [Resolved] Picture in ACCESS

Oh.. yes. This actually works great. Thanks.

I just usually try to avoid unnecessary steps. Even tho I still believe there *should* be a way, I wouldn't even bother to change my code, at that point.

Thank you
__________________
Christian (Email/MSN: krass_methot@hotmail.com)
Krass is offline   Reply With Quote
Old Jan 26th, 2007, 06:50 PM   #18
tgcngb
New Member
 
Join Date: Jan 07
Posts: 3
tgcngb is an unknown quantity at this point (<10)
Re: [Resolved] Picture in ACCESS

RB! do you have any codes that can make commandbutton into xp style without using a user control/class module. API? thanks!
tgcngb is offline   Reply With Quote
Old Jan 27th, 2007, 04:58 PM   #20
tgcngb
New Member
 
Join Date: Jan 07
Posts: 3
tgcngb is an unknown quantity at this point (<10)
Re: [Resolved] Picture in ACCESS

sorry. i forgot to think of the topic. but, if you still have something, hope you can share it. thanks!
tgcngb is offline   Reply With Quote
Old Jan 27th, 2007, 05:24 PM   #21
RhinoBull
PowerPoster
 
RhinoBull's Avatar
 
Join Date: Mar 04
Location: New Amsterdam
Posts: 21,118
RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)
Re: [Resolved] Picture in ACCESS

Try to use the search - it's very handy. Searching this forum for something like "XP styles" will most definitely return you bunch of pages with samples.
RhinoBull is offline   Reply With Quote
Old Jan 29th, 2007, 02:14 AM   #22
tgcngb
New Member
 
Join Date: Jan 07
Posts: 3
tgcngb is an unknown quantity at this point (<10)
Re: [Resolved] Picture in ACCESS

ok. tnx rb!
tgcngb is offline   Reply With Quote
Old May 14th, 2007, 04:53 AM   #23
CharlieK
New Member
 
Join Date: May 07
Posts: 3
CharlieK is an unknown quantity at this point (<10)
Re: [Resolved] Picture in ACCESS

Hi guys,
do you know how can i use this code with vb2005?
= RhinoBull's posted - The insertion pictor to database =
CharlieK is offline   Reply With Quote
Old May 15th, 2007, 02:54 AM   #25
CharlieK
New Member
 
Join Date: May 07
Posts: 3
CharlieK is an unknown quantity at this point (<10)
Re: [Resolved] Picture in ACCESS

Thanks Rhino. But expected similar result, for vb.net, how i write the code?
CharlieK is offline   Reply With Quote
Old Sep 20th, 2007, 05:17 AM   #26
nUflAvOrS
Hyperactive Member
 
nUflAvOrS's Avatar
 
Join Date: Jul 07
Location: Malaysia/ Currently at Singapore
Posts: 363
nUflAvOrS is an unknown quantity at this point (<10)
Re: [Resolved] Picture in ACCESS

If I want to save the file or image to database
What type of Data Type i should use ?

Thanks for advice
__________________
Where there is no hope, there can be no endeavor.

There are two ways of rising in the world, either by your own industry or by the folly of others.
nUflAvOrS is offline   Reply With Quote
Old Sep 20th, 2007, 07:18 AM   #27
Krass
Hyperactive Member
 
Krass's Avatar
 
Join Date: Aug 00
Location: Montreal
Posts: 442
Krass is on a distinguished road (10+)
Re: [Resolved] Picture in ACCESS

hey nUflAvOrS..

I use the "OLE Object" data type in my databases to store pictures......
__________________
Christian (Email/MSN: krass_methot@hotmail.com)
Krass is offline   Reply With Quote
Old Sep 20th, 2007, 07:32 AM   #28
RhinoBull
PowerPoster
 
RhinoBull's Avatar
 
Join Date: Mar 04
Location: New Amsterdam
Posts: 21,118
RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)RhinoBull is a name known to all (1000+)
Re: [Resolved] Picture in ACCESS

That would be any type that is compatible with BLOB - different db engines have different naming conventions but some of them identical so you really need to experiment.
RhinoBull is offline   Reply With Quote
Old Oct 1st, 2007, 08:50 PM   #29
nUflAvOrS
Hyperactive Member
 
nUflAvOrS's Avatar
 
Join Date: Jul 07
Location: Malaysia/ Currently at Singapore
Posts: 363
nUflAvOrS is an unknown quantity at this point (<10)
Re: [Resolved] Picture in ACCESS

Thanks Krass and RhinoBull, I will try your method.
If got any problem i will ask the question here again.
Thanks !
__________________
Where there is no hope, there can be no endeavor.

There are two ways of rising in the world, either by your own industry or by the folly of others.
nUflAvOrS is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:01 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.