davesil2 Posted October 27, 2003 Posted October 27, 2003 I'm trying to use an access database (which works great) as my main database with VB. I have been able to add, delete, update rows without difficulty. I'm looking for help in saving system files into the database for a special purpose program. I am using the OLE Object type in the access database to store files and don't know how to use them in VB.net. I have searched the forum for help with this but to no avale. Please help me. Quote
davesil2 Posted November 1, 2003 Author Posted November 1, 2003 I figured out what I need to do with my code here is how it works. for saving the file to access/SQL use the following (pseudo code) This is not full code but assumes you have a data connection and know how to access the record in the dataset row public function() dim fs as filestream = filestream("c:\test.jpg", filemode.openorcreate, fileaccess.read) dim rawdata() as byte = new byte(fs.length) {} fs.read(rawdata, 0, convert.toint32(fs.length)) fs.close rwfile("file") = rawdata ' rwfile is the record for the ole object in access end function writing the file back to your system should go as follows (psuedo code) public function writedata() dim mydata() as byte = (file in your dataset) dim k as long = ubound(mydata) dim fs as new filestream("c:\test.jpg", filemode.openorcreate, fileaccess.write) fs.write(mydata, 0, k) fs.close() end function Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.