32 users online (0 members and 32 guests)  


  Results 1 to 1 of 1

Related

  1. xml file reading    Forum: Javascript Forum
    Replies: 0
  2. Reading file from different HD    Forum: CGI Perl Forum
    Replies: 0
  3. reading data from the textarea type    Forum: ASP Forum
    Replies: 9
  4. Regarding .XLS file reading and display    Forum: CGI Perl Forum
    Replies: 0
  1. #1
    vennly's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2003
    Location
    penang
    Posts
    1

    Unhappy reading from text file to textarea using vbscript

    hi,

    I need some help here, I want to use vbscript to read the data from text file and display to textarea. I only able to run at server side but failed at client side.

    Will appreciate if you can help me to solve this problem. Thank You.

    <!--#include file="include/DBConn.asp"-->
    <%
    sLoadSql="select * from tech_device"
    set rsLoad=server.createobject("adodb.recordset")
    set rsLoad = cn.Execute(sLoadSql)

    if rsLoad.eof and rsLoad.bof then

    response.write (" no data ")

    else
    response.write ("1st column : " & rsLoad.fields(0))

    rsLoad.Close
    set rsLoad=Nothing
    'Response.End
    end if

    %>
    <br>
    <%=date()%>

    <%
    sFileName = "c:/inetpub/wwwroot/limit/LimitCheck.txt"
    set objFSO = CreateObject("Scripting.FileSystemObject")
    set objFile = objFSO.OpenTextFile(sFileName)
    Do While Not objFile.AtEndOfStream
    intLineNum = objFile.line
    'strLineNum = Right("00" & CSTR(intLineNum),3 )
    StrLineTxt = objFile.ReadLine
    response.write "<BR>" & intLineNum & " : " & StrLineTxt
    aData = Split(StrLineTxt,",")
    i = 0
    while( i<6)
    'response.write "<br>" & aData(i)
    i = i+1
    wend
    Loop
    objFile.close

    %>



    <SCRIPT LANGUAGE="VBScript" >
    Function ReadTextFile()

    FileName = "c:/inetpub/wwwroot/limit/LimitCheck.txt"
    Const adTypeText = 2

    'Create Stream object
    Dim BinaryStream
    Set BinaryStream = CreateObject("ADODB.Stream")

    'Specify stream type - we want To get binary data.
    BinaryStream.Type = adTypeText

    'Specify charset For the source text (unicode) data.
    'If Len(CharSet) > 0 Then
    BinaryStream.CharSet = "ASCII"
    'End If

    'Open the stream
    BinaryStream.Open

    'Load the file data from disk To stream object
    BinaryStream.LoadFromFile FileName

    'Open the stream And get binary data from the object
    ReadTextFile = BinaryStream.ReadText
    msgbox "text : " & len(ReadTextFile) & ReadTextFile

    End Function
    </script>

    <SCRIPT LANGUAGE="VBScript" RUNAT=SERVER>

    function load()
    sFileName = "c:/inetpub/wwwroot/limit/LimitCheck.txt"
    set objFSO = CreateObject("Scripting.FileSystemObject")
    set objFile = objFSO.OpenTextFile(sFileName)
    Do While Not objFile.AtEndOfStream
    intLineNum = objFile.line
    'strLineNum = Right("00" & CSTR(intLineNum),3 )
    StrLineTxt = objFile.ReadLine
    document.myform.taShow.value = "<BR>" & intLineNum & " : " & StrLineTxt

    msgbox "app : "& StrLineTxt
    aData = Split(StrLineTxt,",")
    i = 0
    while( i<6)
    window.document.myform.taShow.value = aData(i)

    i = i+1
    wend
    Loop
    objFile.close
    end function
    </script>

    <html>
    <body onload= "ReadTextFile()">
    <form name="myform">
    <textarea name ="taShow" rows="10" cols="30">
    </textarea>
    </form>
    </body>
    </html>
    Last edited by vennly; 12-05-2003 at 03:40 AM.



Tags for this Thread