Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Article Display help needed? code attached


Message #1 by "Ralph Hardwick" <ralph@p...> on Thu, 15 Aug 2002 17:19:55
Hi,

I am using the following code to *try* and display and article from my 
database (although the story is a generated txt file).

<%@ Language=VBScript %>

<% Response.Buffer = True %>

<%
Dim Connect_String
Dim oConn, oTextStream, oFso, oRs
Dim sPath							
Const fsoForReading = 0

Connect_String = "prodtracCM"

id = Request.QueryString("ID")

Set MyConn=Server.CreateObject("ADODB.Connection")
Set RS=Server.CreateObject("ADODB.RecordSet")

MyConn.Open Connect_String

SQLString = "SELECT * FROM news WHERE id = '"& iId &"'"

RS.Open SQLstring, MyConn, 2, 2

sPath = server.MapPath("/beta/cm/uploaded/id")
Set oFso =  Server.CreateObject("Scripting.FileSystemObject")
Set oTextStream = oFso.OpenTextFile(sPath & iId & ".txt", fsoForReading, 
True)
%>

<table border=0 cellpadding=0 cellspacing=0 width=500>
<tr>
<td>
<% Response.write oTextStream %>
</td>
</tr>
</table>
<%
RS.Close
Set RS = Nothing
MyConn.Close
Set MyConn = Nothing
%>

Anyone got any thoughts on why it does not work?
Please!

cheers.
Message #2 by "Young, Ashley" <Ashley.Young@c...> on Thu, 15 Aug 2002 17:26:19 -0400
It may or may not be as simple as this, but I've always had trouble when
putting single quotes ' around an id number. Try:
SQLString = "SELECT * FROM news WHERE id = "& iId
Best of luck to you. ;)

--Ashley

-----Original Message-----
From: Ralph Hardwick [mailto:ralph@p...]
Sent: Thursday, August 15, 2002 12:20 PM
To: Access ASP
Subject: [access_asp] Article Display help needed? code attached


Hi,

I am using the following code to *try* and display and article from my 
database (although the story is a generated txt file).

<%@ Language=VBScript %>

<% Response.Buffer = True %>

<%
Dim Connect_String
Dim oConn, oTextStream, oFso, oRs
Dim sPath							
Const fsoForReading = 0

Connect_String = "prodtracCM"

id = Request.QueryString("ID")

Set MyConn=Server.CreateObject("ADODB.Connection")
Set RS=Server.CreateObject("ADODB.RecordSet")

MyConn.Open Connect_String

SQLString = "SELECT * FROM news WHERE id = '"& iId &"'"

RS.Open SQLstring, MyConn, 2, 2

sPath = server.MapPath("/beta/cm/uploaded/id")
Set oFso =  Server.CreateObject("Scripting.FileSystemObject")
Set oTextStream = oFso.OpenTextFile(sPath & iId & ".txt", fsoForReading, 
True)
%>

<table border=0 cellpadding=0 cellspacing=0 width=500>
<tr>
<td>
<% Response.write oTextStream %>
</td>
</tr>
</table>
<%
RS.Close
Set RS = Nothing
MyConn.Close
Set MyConn = Nothing
%>

Anyone got any thoughts on why it does not work?
Please!

cheers.

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.377 / Virus Database: 211 - Release Date: 7/15/2002
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.377 / Virus Database: 211 - Release Date: 7/15/2002
 

  Return to Index