Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...