Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-12-2002, 10:44 AM   PM User | #1
bassleader
New Coder

 
Join Date: Jun 2002
Location: Caerdydd
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
bassleader is an unknown quantity at this point
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
bassleader is offline   Reply With Quote
Old 08-13-2002, 09:07 AM   PM User | #2
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
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.
raf is offline   Reply With Quote
Old 08-14-2002, 10:00 PM   PM User | #3
bassleader
New Coder

 
Join Date: Jun 2002
Location: Caerdydd
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
bassleader is an unknown quantity at this point
Thanks raf.

What does the code in update.asp look like?

BL
__________________
"nam et ipsa scientia potentas est" - Francis Bacon
bassleader is offline   Reply With Quote
Old 08-15-2002, 06:14 PM   PM User | #4
whammy
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
whammy is an unknown quantity at this point
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. ;)
whammy is offline   Reply With Quote
Old 08-16-2002, 10:36 PM   PM User | #5
bassleader
New Coder

 
Join Date: Jun 2002
Location: Caerdydd
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
bassleader is an unknown quantity at this point
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
bassleader is offline   Reply With Quote
Old 08-19-2002, 12:16 AM   PM User | #6
whammy
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
whammy is an unknown quantity at this point
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. ;)
whammy is offline   Reply With Quote
Old 08-19-2002, 07:44 PM   PM User | #7
bassleader
New Coder

 
Join Date: Jun 2002
Location: Caerdydd
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
bassleader is an unknown quantity at this point
I'll do that. If I find anything I'll post it here.

BL
__________________
"nam et ipsa scientia potentas est" - Francis Bacon
bassleader is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:04 AM.


Advertisement
Log in to turn off these ads.