Results 1 to 4 of 4

Thread: [RESOLVED] I need help on attching files in VB2005

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2008
    Posts
    104

    Resolved [RESOLVED] I need help on attching files in VB2005

    Hello evryone:

    I need some help and i am hoping someone can help me;

    I am working on a project and I would like to add an attachment option, where the user will be able to add any type of file (attachment) and be able to be save into an SQL2005 database

    Can someone provime with some sample code?

    Thanks you so much

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: I need help on attching files in VB2005

    This link talks about images, but it can really be any file type:

    http://www.vbforums.com/showthread.php?t=469562

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: I need help on attching files in VB2005

    In that example of mine the Image object is saved to a MemoryStream and then the contents of that Stream is saved to the database. If you're saving a file then you'd create a FileStream and save the contents of that Stream to the database.

    Just note that saving files in databases is a great way to make them grow very quickly and thus become less efficient. Storing files in the file system is preferable if it can be done.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: I need help on attching files in VB2005

    Quote Originally Posted by jmcilhinney
    Just note that saving files in databases is a great way to make them grow very quickly and thus become less efficient. Storing files in the file system is preferable if it can be done.
    Just to add to JMC's point, if for some reason a user accidently deletes the attachment, restoring that from a backup can be a pain if it stored in the database, because you have to restore a single row.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width