Transferring data from text file to html form and then to database using asp

Results 1 to 5 of 5

Thread: Transferring data from text file to html form and then to database using asp

  1. #1
    Join Date
    Dec 1969
    Posts
    30

    Default Transferring data from text file to html form and then to database using asp

    I want to read some data from a text file like<BR>1.23<BR>4.56<BR>5.89<BR>etc and to display it on a from field in the same format. This data should then be stored in a database(Access) table. The format in which it is saved doesnt matter. But when the from is reloaded after some time, it should be able to retrieve the stored information in the table back into the form field(text box) in the same format(as diplayed above). <BR>Could you please help me with this. I have been struggling with this since a long time. <BR><BR>Thanx in anticipation, <BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    30

    Default same question expressed in a better way

    I want to read some data from a text file in which after each line there is a &#039/n&#039 new line character.for eg<BR>1.23<BR>4.56<BR>5.89<BR>etc. I want to then display it on a from field in the same format. The problem is that in the form field the &#039/n&#039 character is ignored and the form results in a single line, like this<BR>1.234.565.89<BR>I am using the following code to read data from a file <BR>&#060;%<BR> const TristateUseDefault = -2, ForReading = 1<BR> Dim FSObj, FSOFile, FSOStream &#039File System Objects<BR> Dim strText, FileName &#039Strings<BR><BR> FileName = "file.txt"<BR> strphysicalpath = Server.MapPath(FileName)<BR><BR> Set FSObj = Server.CreateObject ("Scripting.FileSystemObject")<BR> Set FSOFile = FSObj.GetFile (strphysicalpath)<BR> strText = "" <BR> Set FSOStream = FSOFile.OpenAsTextStream(ForReading, TristateUseDefault)<BR> Do While Not FSOStream.AtEndOfStream<BR> strText = strText & FSOStream.Readline<BR> Loop<BR>&#037;&#062; <BR><BR>Can any body help me with this?<BR><BR>This data should then be stored in a Memo field of database(Access) table. Again if the data in the form is in the original format(with newline character at the end of each line) like,<BR>1.2<BR>2.3<BR>4.5 <BR>etc. then only the first line is saved in the memo field and the rest is ignored.So only 1.2 is saved in the database.<BR><BR>Could you please help me with this? I have been struggling with this since a long time. <BR><BR>Thanx in anticipation, <BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: same question expressed in a better way

    I am not sure I fully understand your question, but here, let me give a wack at it.<BR><BR>It sounds like you are having two problems: first, all of your lines are not read in using FSO; second, the newline character is not being displayed as a break.<BR><BR>Here is what I propose you do:<BR><BR>#1.) Read the entire file into a string variable using the .ReadAll method:<BR><BR>strFile = FSOStream.ReadAll<BR><BR>#2.) Replace all chr(13) (
    &#039s) with vbCrLf (chr(10), I think)<BR><BR>strFile = Replace(strFile,chr(13),chr(10))<BR><BR>#3.) Slap that string variable (strFile) into your Access memo field.<BR><BR>Let me know if this works for you... happy programming!

  4. #4
    Join Date
    Dec 1969
    Posts
    30

    Default RE: same question expressed in a better way

    Thanks Mitchell,<BR>It did work for me.<BR><BR>Thanks again. Hope we would be in contact sooner again.


  5. #5
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: same question expressed in a better way

    Well, if you have more questions, just ask them here. Also, be sure to see if you can&#039t help others by answering there questions! :)

Posting Permissions

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