| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi all, I want to save the Picture object into a Long Binary (OLE Object) field in a mdb database without using the data control. Could not find any direction searching the web. Anyone knows an example? Thanks in advance. Paulo |
|
#2
| |||
| |||
| "Paulo" <nospam.pmp_costa@netcabo.pt> wrote in message news:uJKOoSPDJHA.5196@TK2MSFTNGP04.phx.gbl... > Hi all, > > I want to save the Picture object into a Long Binary (OLE Object) field in a > mdb database without using the data control. Could not find any direction > searching the web. > > Anyone knows an example? > Your post is a bit confusing since you use the expression "Long Binary (OLE Object) field". Note these are actually two different things. While internally the storage may be the same - Jet handles them as two distinct datatypes. For example, Dates are nothing more than a double, but Jet knows Doubles and Dates. [Also I'm assuming your are using Classic VB (VB6 and lower) and not dotNet. DotNet provides additional tools for binding images from storage with controls. If using dotNet you need to post to a dotNet newsgroup and ask about .DataBindings and .MemoryStream.] Since you posted to a DAO newsgroup, I am assuming you are using DAO. AFAIK, you cannot do this with DAO without going through the OLE Container control. (Hopefully I'm wrong. I often am. But I have never seen any code to do it. But again what in programming is impossible?) You can do it without the OLE Container control with ADO using AppendChunk. With yet one more fly in the ointment - you can load a 'file' or the binary of the picture - but no practical way in VB to load the 'PictureBox' without the OLE Container control. That's why you use it - it wraps your image as an OLE Object. Last I have to add this piece of unsolicited advice. Adding pictures and other binary objects to a MSAccess 'file-based' database seems like a good idea. It sure looks neat in the demos and tutorials. But it scales very poorly. It doesn't take many objects to throughly bloat an mdb file which will effect performance and maintance. The problems will go up geometrically if the database is shared. A better strategy is store your 'pictures' as separate files and keep the location and name in the database. You can wrap this location with code to provide management. -ralph |
|
#3
| |||
| |||
| Hi Ralph, Thanks for replying. I am using classic vb (VB6) and DAO 3.51 Object Library. At this moment I could already resolve my problem. I found a corresponding example with ADO at VB Helper here: http://www.vb-helper.com/howto_db_dib.html Is this case I am maintaining an old application and adding a few new capabilities, one of them is to store companies logos and other images. The field is of type dbLongBinary (type 11). By using the AppendChunk and GetChunk methods it is possible to save and load any DIB bits. The database file (MDB) is shared in a machine of the costumer's network and at this moment the application has been tested and accessed by more than 15 people simultaneously. No problems found till now. It would have been very hard to rewrite the entire application in .net, so my chance is to maintain it as long as I can... Thanks Ralph |
|
#4
| |||
| |||
| "Paulo" <nospam.pmp_costa@netcabo.pt> a écrit dans le message de news: uJKOoSPDJHA.5196@TK2MSFTNGP04.phx.gbl... > Hi all, > > I want to save the Picture object into a Long Binary (OLE Object) field in a > mdb database without using the data control. Could not find any direction > searching the web. > > Anyone knows an example? > > Thanks in advance. > > Paulo > > Hello Paulo, Excusez mon anglais, mais il me semble que c'est ce que vous cherchez (VB5 sp2) Salutations et bon code... SO ' ########## Option Explicit Dim db As Database Dim wrkDefault As Workspace Dim rs As Recordset Dim tableau() As Byte, ff Private Sub Command1_Click() ff = FreeFile Open "c:\windows\test.bmp" For Binary As #ff ReDim tableau(1 To LOF(ff)) Get #ff, , tableau Close #ff Set wrkDefault = DBEngine.Workspaces(0) If Dir(App.Path & "\BD1.MDB") <> "" Then Kill App.Path & "\BD1.MDB" Set db = wrkDefault.CreateDatabase(App.Path & "\BD1.MDB", dbLangGeneral) db.Execute "CREATE TABLE table1 " & "(champ1 LONGBINARY);" db.Close Set db = OpenDatabase(App.Path & "\BD1.MDB") Set rs = db.OpenRecordset("Table1", dbOpenDynaset) rs.AddNew rs!champ1 = tableau Open App.Path & "\resultat.bmp" For Output As #ff Print #ff, StrConv(rs.Fields(0), vbUnicode); Close #ff rs.Update db.Close End Sub ' ########## |
|
#5
| |||
| |||
| "Paulo" <nospam.pmp_costa@netcabo.pt> wrote in message news:%23Z$5A7CEJHA.1280@TK2MSFTNGP02.phx.gbl... > Hi Ralph, > > Thanks for replying. I am using classic vb (VB6) and DAO 3.51 Object > Library. At this moment I could already resolve my problem. I found a > corresponding example with ADO at VB Helper here: > > http://www.vb-helper.com/howto_db_dib.html > > Is this case I am maintaining an old application and adding a few new > capabilities, one of them is to store companies logos and other images. The > field is of type dbLongBinary (type 11). By using the AppendChunk and > GetChunk methods it is possible to save and load any DIB bits. The database > file (MDB) is shared in a machine of the costumer's network and at this > moment the application has been tested and accessed by more than 15 people > simultaneously. No problems found till now. > > It would have been very hard to rewrite the entire application in .net, so > my chance is to maintain it as long as I can... > > Thanks Ralph > Thanks for the feedback. ADO AppendChunk/GetChunk is usually the best solution. My warning was more directed to 'quanity' and not to problems with the storage and retrieval itself. -ralph |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.