dcsimg
Results 1 to 9 of 9

Thread: How to send and retrieve Text file from the database!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2008
    Posts
    20

    How to send and retrieve Text file from the database!

    does anyone here can help me and guide me through this matter!?

    thank you very very much more!
    Last edited by jzarapsa; Jan 23rd, 2008 at 01:08 AM.

  2. #2
    Junior Member
    Join Date
    Nov 2007
    Posts
    22

    Re: How to send and retrieve Text file from the database!

    Here's an ADO faq for adding image files, but it can be modified to work with other file types.

    HTH

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2008
    Posts
    20

    Re: How to send and retrieve Text file from the database!

    how about some text files!? how to save and retrieve it from the database!? using VB6 or VB.nET

    does the code in saving images and retrieving from the database is the same as saving text files and retrieving

    it!?

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: How to send and retrieve Text file from the database!

    Unless the text will be huge records, you don't need to chunk it. Just INSERT records with the text to save it to the database and SELECT the records you want to retrieve it from the database.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  5. #5
    Junior Member
    Join Date
    Nov 2007
    Posts
    22

    Re: How to send and retrieve Text file from the database!

    Quote Originally Posted by jzarapsa
    how about some text files!? how to save and retrieve it from the database!? using VB6 or VB.nET

    does the code in saving images and retrieving from the database is the same as saving text files and retrieving

    it!?
    If you're using ADO and really wish to add the file itself, then load the contents of the file - any file. Follow the faq and replace the image data with that of fdata
    Code:
    dim fdata() as byte
    ffnum as integer
    fsize as long
    
    ffnum = freefile
    fsize = filelen(textfile)
    redim fdata(fsize) as byte
    
    open textfile for binary access read as #ffnum
    get #ffnum, , fdata
    close #ffnum
    
    erase fdata
    
    ' use faq to store the file's size (fsize) and its data (fdata)
    To retrieve the file, follow the faq for the image, and then try
    Code:
    dim fdata() as byte
    ffnum as integer
    fsize as long
    
    ffnum = freefile
    fsize = adodbrecordset.fields("filesize")
    redim fdata(fsize) as byte
    fdata = adorecordset.fields("filedata").getchunk(fsize)
    
    open outputfile for binary access write as #ffnum
    put #ffnum, , fdata
    close #ffnum
    
    erase fdata
    When you create the table, add fields for the filesize and filedata as was done in the faq. You can add a filename field too if you wish and then use that to output the file.

    The above isn't tested, but hopefully I remembered it right. I used it on a VB6 app a while back.

    HTH

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jan 2008
    Posts
    20

    Re: How to send and retrieve Text file from the database!

    thumbs up for you! hehe, well i hope this code will help, but it's worth tryng!

    tnx men!

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jan 2008
    Posts
    20

    Re: How to send and retrieve Text file from the database!

    uhmmm.. one more thing... how can i view the text file!?? can I also edit the data!?
    and were should place those codes!? im just a noob in vb hehe!

    can you please attach some ebooks for vb6 and vb.net!? if you have so that i can read and study...

    tnx mah men! ^^
    Last edited by jzarapsa; Jan 25th, 2008 at 01:27 AM.

  8. #8
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: How to send and retrieve Text file from the database!

    For an instance like this, why are you saving the file? Why not just save the text of the file and, if need be, write it out to a text file on the fly?

    BTW: What kind of database are you using?
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jan 2008
    Posts
    20

    Red face Re: How to send and retrieve Text file from the database!

    Quote Originally Posted by Hack
    For an instance like this, why are you saving the file? Why not just save the text of the file and, if need be, write it out to a text file on the fly?

    BTW: What kind of database are you using?

    I'm using MySQL 5, about your suggestion how can i do that!? can you teach me!? or can you please send me some ebooks or any tutorials about VB6 or VB.NET!? i'm just a newbie in VB6, i only know how to add, edit, delete, view(not too much), search in short! BASICS!
    Last edited by jzarapsa; Jan 28th, 2008 at 08:23 PM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width