In Foxpro it's been said over and over not to store binary data in a general field but instead only store a pointer to the file name on disk.
Wouldn't that apply to MS SQL too? --- On Fri, 5/29/09, Stephen Russell <[email protected]> wrote: > From: Stephen Russell <[email protected]> > Subject: Re: File corruption when storing/retrieving files in MSSQL backend. > To: "ProFox Email List" <[email protected]> > Date: Friday, May 29, 2009, 1:57 PM > On Fri, May 29, 2009 at 11:54 AM, > Vince Teachout <[email protected]> > wrote: > > Hi, all. > > > > I'm having a very frustrating problem, and hoping > someone can send the > > clue fairy over. > > > > In one of our apps, which has traditionally used a VFP > backend, we have > > the ability for the user to store files into memo > fields in the > > database, then later retrieve them and view them, > based on file > > extension, with whatever the default handler is for > that extension on > > their computer. > > > > So the (simplified) gist is: > > > > Saving the attachement: > > cBinData = FILETOSTR("myfile.pdf") > > INKEY(1) && give time to finish > > INSERT INTO MyATTACHMENTS (Attachkey, > Bindata) ; > > VALUES > (cAttachkey, cBinData) > > > > Retreiving is: > > COPY MEMO bindata TO ("MyTempFile.pdf") > > > > Viewing is simply a call to shellexec, which works > fine. > > > > We've never had problems with this in a vfp backend, > but now that we're > > using MSSQL, users are complaining of corrupted files. > One client looks > > like they are having PDF files corrupted during save, > another has some > > issue where all but two bytes of the pdf file are > copied out during the > > retrieve, causing Adobe reader to fail. Of course, > it works fine here, > > and I can't duplicate either problem. > > > > We're all using MSSQL 2005, and the BinData memo field > on the SQL server > > is a TEXT field. > > > > Would happily welcome any flames or slights on my > coding ability, as > > long as they contain clues, as well. Thanks! > ----------------------------- > > > Try are read here on writetext and readtext instead of > insert / select > http://doc.ddart.net/mssql/sql70/wa-wz_3.htm > http://doc.ddart.net/mssql/sql70/ra-rz_3.htm > > You are setting the the proper data handler in your > statement with > these commands. > > I looked into doing this for M$ doc files a few years ago > and found > this the ONLY way I got the .doc file out of the db > properly. We > chose not to do this because we couldn't search the doc > file's text, > an initial requirement of the project. > > Secondly I would not convert the .pdf to text. > Granted I was using a > streamreader in .NET to read my files inbound. > > I have to say that PDF is a bit tough for this sort of > thing and you > may find that your filesize is HUGE in an every once in a > while > situation. > > > > -- > Stephen Russell > Sr. Production Systems Programmer > Web and Windows Development > Independent Contractor > Memphis TN > > 901.246-0159 > > _______________________________________________ > Post Messages to: [email protected] > Subscription Maintenance: http://leafe.com/mailman/listinfo/profox > OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech > Searchable Archive: http://leafe.com/archives/search/profox > This message: > http://leafe.com/archives/byMID/profox/[email protected] > ** All postings, unless explicitly stated otherwise, are > the opinions of the author, and do not constitute legal or > medical advice. This statement is added to the messages for > those lawyers who are too stupid to see the obvious. > _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[email protected] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

