Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    Caerdydd
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using Wordpad files in Access databases

    Hi,

    I am working with an Access database with Wordpad documents as one of the fields. How can I extract the text from these documents to include it in a webpage? The code I am using at the moment generates an error (this is ASP and Javascript):

    in HEAD -----------------------
    <%
    var Recordset1 = Server.CreateObject("ADODB.Recordset");
    Recordset1.Source = "SELECT * FROM table1";
    var textob = Server.CreateObject("Scripting.FileSystemObject");
    var text = textob.OpenTextFile(Recordset1.Fields.Item("doc_text").Value);
    %>

    in BODY-----------------------
    <table width="100%" height="45">
    <tr>
    <td><%=(Recordset1.Fields.Item("title").Value)%></td>
    </tr>
    <tr>
    <td><%=Response.write(text.ReadAll);
    text.Close;
    %>
    </td>
    </tr>
    </table>

    table1 has two fields, "title" and "doc_text", representing the document title and the document text respectively. The document text is held in a Wordpad file. At some point I want to use an HTML form to edit the files as well. Is this possible?

    Cheers,

    BL
    "nam et ipsa scientia potentas est" - Francis Bacon

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    About your last question :
    yep. it's even very easy. just create a form with a textarea and insert the data from your recordset in it. Just like the example below (I use VB, sory)


    <form name="FormName" action="update.asp" method="post">
    <textarea name="textareaName" cols="40" rows="4"><%response.write("rs1.Fields("doc_text")%></textarea>
    </form>

    The text can be edited and is then send to update.asp where you can update the record in your database.

  • #3
    New Coder
    Join Date
    Jun 2002
    Location
    Caerdydd
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks raf.

    What does the code in update.asp look like?

    BL
    "nam et ipsa scientia potentas est" - Francis Bacon

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <%
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open 'Put your connection string here!
    
    UpdateQuery = "UPDATE your_table_name SET doc_text = '" & doc_text & "' WHERE yourprimarykey = '" & whateverVariableYouSetUsingThePrimaryKeyInYourDatabase & "'"
    
    'Response.Write(UpdateQuery) ' For debugging
    Conn.Execute(UpdateQuery)
    
    Conn.Close
    Set Conn = Nothing
    %>
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #5
    New Coder
    Join Date
    Jun 2002
    Location
    Caerdydd
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cool. I'm still having difficulties writing these files to the page though. I thought it would be a matter of using the same code I would to open an ordinary text file on the server and replacing the name of the text file with the field of the recordset, but that doesn't seem to work. Any ideas?

    BL
    "nam et ipsa scientia potentas est" - Francis Bacon

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'd do some research on SQL statements - google or something should turn up plenty of them!
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #7
    New Coder
    Join Date
    Jun 2002
    Location
    Caerdydd
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'll do that. If I find anything I'll post it here.

    BL
    "nam et ipsa scientia potentas est" - Francis Bacon


  •  

    Posting Permissions

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