Question regarding the Record object and Stream Ob

Results 1 to 2 of 2

Thread: Question regarding the Record object and Stream Ob

  1. #1
    Viktor A Lundberg Guest

    Default Question regarding the Record object and Stream Ob

    Hello, I&#039;m kinda new at ASP so please bear with me on this one.<BR><BR>I&#039;m using the wrox beginning ASP book and I&#039;m now on the chapter on the record and stream objects. The trouble I have with these is that none of the examples work. I know I have typed the code in correctly.<BR>The thing that happens with the record object is that when the browser tries to access it it just kinda hangs and does none of the processing it should.<BR><BR>With the stream object I tried this example that I found on this site and I just get a &#039;file could not be opened&#039; error.<BR>Here is the code for that one:<BR><BR>&#060;!--METADATA TYPE="typelib"<BR> UUID="00000205-0000-0010-8000-00AA006D2EA4"<BR> NAME="ADODB Type Library"<BR>--&#062;<BR>&#060;%<BR>&#039;Create a Stream instance<BR>Dim objStream<BR>Set objStream = Server.CreateObject("ADODB.Stream")<BR>&#039;Open the stream<BR>objStream.Open <BR>objStream.Type = adTypeText<BR>objStream.Charset = "ascii" <BR>objStream.LoadFromFile "message.txt" <BR>&#039;Move the position to the end of the stream...<BR>objStream.Position = objStream.Size <BR>objStream.WriteText "Buy a copy of Designing Active Server Pages!!!" <BR>objStream.SaveToFile "C:StreamDemo.txt", adSaveCreateOverwrite <BR>&#039;Close the stream and set it to nothing...<BR>objStream.Close<BR>Set objStream = Nothing<BR>%&#062;<BR>I&#039;ve tried all putting the necessary files in different places and yet it always gives me that result.<BR><BR>Sorry for my rambling.<BR>Any help on this is greatly appreciated.<BR><BR>Regards:<BR><BR>Viktor

  2. #2
    Join Date
    Dec 1969

    Default I don't see Record object in there... any of that code.<BR><BR>Oh, well.<BR><BR>Anyway, you did not tell us *WHERE* you were getting the error. Nor did you copy/paste the actual error message.<BR><BR>I will *guess* that you got the error here:<BR><BR>objStream.LoadFromFile "message.txt" <BR><BR>Do you know *exactly* what file you tried to load from, with that? *Probably* from c:windowssystemmessage.txt or c:program filesxxxyyymessage.txt <BR><BR>You need to give the *FULL* path to a file, not just a relative path. You can use Server.MapPath to convert a relative path to an absolute one.<BR><BR>For example:<BR><BR>objStream.LoadFromFile Server.MapPath("message.txt")<BR><BR>will ask for a file that is in the same directory as the currently executing ASP page. Other relative positions are easy. See the docs for MapPath.<BR><BR>If that&#039;s not the line where you got the error...<BR><BR>Post again?<BR><BR><BR>

Posting Permissions

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