Print Page | Close Window

using common.asp connection

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=4515
Printed Date: 30 March 2026 at 10:06am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: using common.asp connection
Posted By: Badaboem
Subject: using common.asp connection
Date Posted: 25 July 2003 at 3:16am

I'm trying to incorperate a script into my website and use the forum's database. I've copied the required database fields and it works with the connection type I setup below.

I would like to use common.asp though to setup the connection. I've looked at some of the modules available for webwiz, and tried to duplicate it without suc6..

Can anybody help me? Thanks in advance.

below is part of the code without common.asp


<%
SET Conn = Server.CreateObject("ADODB.Connection")
SET RS = Server.CreateObject("ADODB.RecordSet")

sConnDatabase = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & Server.MapPath("/xxx.mdb")
SUB OpenDB(sConn)
 Conn.Open sConn
 SET RS.ActiveConnection = Conn
 RS.CursorType = AdOpenStatic
END SUB

SUB CloseDB(sConn)
 RS.Close
 Conn.Close
END SUB

OpenDB sConnDatabase
IF Request("Upload") = "True" THEN
 Response.Write ("<P ALIGN='Center'><B>You have successfully uploaded a file, we will list your file as soon as it is approved.</B></P>")
END IF
UnapprCount =0
SQL = "SELECT * FROM LibrariesFiles WHERE Approved=False ORDER BY FileName"
SET RS = Conn.Execute(SQL)
DO WHILE NOT RS.EOF
UnapprCount = UnapprCount + 1
RS.MoveNext

here what I tried with common.asp

<!--#INCLUDE virtual="/xx/common.asp"-->
<%
IF Request("Upload") = "True" THEN
 Response.Write ("<P ALIGN='Center'><B>You have successfully uploaded a file, we will list your file as soon as it is approved.</B></P>")
END IF

UnapprCount =0
strSQL = "SELECT * FROM LibrariesFiles WHERE Approved=False ORDER BY FileName"
rsCommon.Open strSQL, adoCon

DO WHILE NOT RScommon.EOF
UnapprCount = UnapprCount + 1
RScommon.MoveNext




Replies:
Posted By: Scotty32
Date Posted: 25 July 2003 at 4:23am

wot are you try to do

and wot is the error you get? (if any :S)

 

could you tell us more?



Posted By: Badaboem
Date Posted: 25 July 2003 at 5:02am

you can see the script at work here: http://129.125.101.174/portal/library3.asp - http://129.125.101.174/portal/library3.asp

Here it is as it was before I implemented common.asp, and the movenext statement works:

<%
SET Conn = Server.CreateObject("ADODB.Connection")
SET RS = Server.CreateObject("ADODB.RecordSet")

sConnDatabase = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & Server.MapPath("/xxx/xxx.mdb")
SUB OpenDB(sConn)
 Conn.Open sConn
 SET RS.ActiveConnection = Conn
 RS.CursorType = AdOpenStatic
END SUB

SUB CloseDB(sConn)
 RS.Close
 Conn.Close
END SUB

OpenDB sConnDatabase
IF Request("Upload") = "True" THEN
 Response.Write ("<P ALIGN='Center'><B>You have successfully uploaded a file, we will list your file as soon as it is approved.</B></P>")
END IF
UnapprCount =0
SQL = "SELECT * FROM LibrariesFiles WHERE Approved=False ORDER BY FileName"
SET RS = Conn.Execute(SQL)
DO WHILE NOT RS.EOF
UnapprCount = UnapprCount + 1
RS.MoveNext
LOOP
 Response.Write ("<BR><B>There are " & UnapprCount & " unapproved files in your libraries.</B></P>")
 Response.Write ("<TABLE WIDTH='95%' BORDER='0' ALIGN='Center' CELLPADDING='1' CELLSPACING='1' CLASS='BGColor03'>")
 Response.Write ("<TR CLASS='BGColor01'>")
 Response.Write ("<TD WIDTH='150' VALIGN='Top'><B>Category Name</B></TD>")
 Response.Write ("<TD><B>Description</B></TD>")
 Response.Write ("</TR>")
SQL = "SELECT * FROM LibrariesCategories ORDER BY CategoryName"
SET RS = Conn.Execute(SQL)
DO WHILE NOT RS.EOF
 Response.Write ("<TR CLASS='BGColor02'>")
 Response.Write ("<TD WIDTH='150' VALIGN='Top'><A HREF='fldisplay.asp?ID=" & RS("ID") & "'>" & RS("CategoryName") & "</A></TD>")
 Response.Write ("<TD VALIGN='Top'>" & RS("Description") & "</TD>")
 Response.Write ("</TR>")
RS.MoveNext
LOOP
 Response.Write ("</TR></TABLE><BR>")
 Response.Write ("<TABLE WIDTH='95%' BORDER='0' ALIGN='Center' CELLPADDING='5' CELLSPACING='5'>")
 Response.Write ("<TR><TD WIDTH='50%'>")

SQL = "SELECT * FROM LibrariesFiles ORDER BY DateUpdated DESC"
SET RS = Conn.Execute(SQL)
 Response.Write ("<TABLE WIDTH='95%' BORDER='0' ALIGN='Center' CELLPADDING='1' CELLSPACING='1' CLASS='BGColor03'>")
 Response.Write ("<TR CLASS='BGColor01'><TD ALIGN='Center' COLSPAN='4'><B>Newest Files Added</B></TD>")
 Response.Write ("</TR><TR CLASS='BGColor01'>")
 Response.Write ("<TD><B>Program Name</B></TD>")
 Response.Write ("<TD WIDTH='80'><B>Date Added</B></TD>")
 Response.Write ("</TR>")
FOR I = 1 TO 10
IF RS.EOF THEN
ELSE
IF RS("Approved") = True THEN
 Response.Write ("<TR CLASS='BGColor02'>")
 Response.Write ("<TD VALIGN='Top'><A HREF='fldetails.asp?ID=" & RS("ID") & "'>" & RS("ProgramName") & "</A></TD>")
 Response.Write ("<TD WIDTH='80' VALIGN='Top'>" & RS("DateUpdated") & "</TD>")
 Response.Write ("</TR>")
END IF
RS.MoveNext
END IF
NEXT
 Response.Write ("</TABLE><BR>")
 Response.Write ("</TD><TD WIDTH='50%'>")
SQL = "SELECT * FROM LibrariesFiles ORDER BY Downloads DESC"
SET RS = Conn.Execute(SQL)
 Response.Write ("<TABLE WIDTH='95%' BORDER='0' ALIGN='Center' CELLPADDING='1' CELLSPACING='1' CLASS='BGColor03'>")
 Response.Write ("<TR CLASS='BGColor01'><TD ALIGN='Center' COLSPAN='4'><B>Most Popular Files</B></TD>")
 Response.Write ("</TR><TR CLASS='BGColor01'>")
 Response.Write ("<TD><B>Program Name</B></TD>")
 Response.Write ("<TD WIDTH='80'><B>Downloads</B></TD>")
 Response.Write ("</TR>")
FOR I = 1 TO 10
IF RS.EOF THEN
ELSE
IF RS("Approved") = True THEN
 Response.Write ("<TR CLASS='BGColor02'>")
 Response.Write ("<TD VALIGN='Top'><A HREF='fldetails.asp?ID=" & RS("ID") & "'>" & RS("ProgramName") & "</A></TD>")
 Response.Write ("<TD WIDTH='80' VALIGN='Top'>" & RS("Downloads") & "</TD>")
 Response.Write ("</TR>")
END IF
RS.MoveNext
END IF
NEXT
 Response.Write ("</TABLE><BR>")
 Response.Write ("</TD></TR></TABLE>")
CloseDB sConnDatabase
%>



Posted By: Scotty32
Date Posted: 25 July 2003 at 5:09am

umm am not sure, but did you miss out the

<% i = i + 1 %>

which i guess could be why its not showing the rest, and only showing 1 record...

umm not sure, jsut an idea

also couldnt you just put "IF NOT RS.EOF THEN" ? and then you can take out the "else" ?

(put the bit of code i had a quick look at)

FOR I = 1 TO 10
IF NOT RS.EOF THEN
IF RS("Approved") = True THEN
 Response.Write ("<TR CLASS='BGColor02'>")
 Response.Write ("<TD VALIGN='Top'><A HREF='fldetails.asp?ID=" & RS("ID") & "'>" & RS("ProgramName") & "</A></TD>")
 Response.Write ("<TD WIDTH='80' VALIGN='Top'>" & RS("Downloads") & "</TD>")
 Response.Write ("</TR>")
END IF
I = I + 1
RS.MoveNext

END IF
NEXT
 Response.Write ("</TABLE><BR>")
 Response.Write ("</TD></TR></TABLE>")
CloseDB sConnDatabase
%>



Posted By: Badaboem
Date Posted: 25 July 2003 at 5:19am

YOu've taken a look at the wrong code  The one you changed DOES work, but doesn't have common.asp included to establish the database connection (i edited my second post and you can see the working code there)..

It's the code below with common.asp included that doesn't work and has the movenext problem and can be seen here.. http://129.125.101.174/portal/library3.asp - http://129.125.101.174/portal/library3.asp

<!--#INCLUDE virtual="/dark project/forum/common.asp"-->
<%
'Craete a recordset to get the forum details
Set rs = Server.CreateObject("ADODB.Recordset")

IF Request("Upload") = "True" THEN
 Response.Write ("<P ALIGN='Center'><B>You have successfully uploaded a file, we will list your file as soon as it is approved.</B></P>")
END IF
UnapprCount =0
strSQL = "SELECT * FROM LibrariesFiles WHERE Approved=False ORDER BY FileName"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, adoCon

DO WHILE NOT RS.EOF
UnapprCount = UnapprCount + 1
RS.MoveNext
LOOP
 Response.Write ("<BR><B>There are " & UnapprCount & " unapproved files in your libraries.</B></P>")
 Response.Write ("<TABLE WIDTH='95%' BORDER='0' ALIGN='Center' CELLPADDING='1' CELLSPACING='1' CLASS='BGColor03'>")
 Response.Write ("<TR CLASS='BGColor01'>")
 Response.Write ("<TD WIDTH='150' VALIGN='Top'><B>Category Name</B></TD>")
 Response.Write ("<TD><B>Description</B></TD>")
 Response.Write ("</TR>")
strSQL = "SELECT * FROM LibrariesCategories ORDER BY CategoryName"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, adoCon
DO WHILE NOT RS.EOF
 Response.Write ("<TR CLASS='BGColor02'>")
 Response.Write ("<TD WIDTH='150' VALIGN='Top'><A HREF='fldisplay.asp?ID=" & RS("ID") & "'>" & RS("CategoryName") & "</A></TD>")
 Response.Write ("<TD VALIGN='Top'>" & RS("Description") & "</TD>")
 Response.Write ("</TR>")
RS.MoveNext
LOOP
 Response.Write ("</TR></TABLE><BR>")
 Response.Write ("<TABLE WIDTH='95%' BORDER='0' ALIGN='Center' CELLPADDING='5' CELLSPACING='5'>")
 Response.Write ("<TR><TD WIDTH='50%'>")

strSQL = "SELECT * FROM LibrariesFiles ORDER BY DateUpdated DESC"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, adoCon
 Response.Write ("<TABLE WIDTH='95%' BORDER='0' ALIGN='Center' CELLPADDING='1' CELLSPACING='1' CLASS='BGColor03'>")
 Response.Write ("<TR CLASS='BGColor01'><TD ALIGN='Center' COLSPAN='4'><B>Newest Files Added</B></TD>")
 Response.Write ("</TR><TR CLASS='BGColor01'>")
 Response.Write ("<TD><B>Program Name</B></TD>")
 Response.Write ("<TD WIDTH='80'><B>Date Added</B></TD>")
 Response.Write ("</TR>")
FOR I = 1 TO 10
SET RS = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, adoCon
IF RS.EOF THEN
ELSE
IF RS("Approved") = True THEN
 Response.Write ("<TR CLASS='BGColor02'>")
 Response.Write ("<TD VALIGN='Top'><A HREF='fldetails.asp?ID=" & RS("ID") & "'>" & RS("ProgramName") & "</A></TD>")
 Response.Write ("<TD WIDTH='80' VALIGN='Top'>" & RS("DateUpdated") & "</TD>")
 Response.Write ("</TR>")
END IF
RS.MoveNext

END IF
 
NEXT
 Response.Write ("</TABLE><BR>")
 Response.Write ("</TD><TD WIDTH='50%'>")
strSQL = "SELECT * FROM LibrariesFiles ORDER BY Downloads DESC"
Set rs = Server.CreateObject("ADODB.Recordset")
 Response.Write ("<TABLE WIDTH='95%' BORDER='0' ALIGN='Center' CELLPADDING='1' CELLSPACING='1' CLASS='BGColor03'>")
 Response.Write ("<TR CLASS='BGColor01'><TD ALIGN='Center' COLSPAN='4'><B>Most Popular Files</B></TD>")
 Response.Write ("</TR><TR CLASS='BGColor01'>")
 Response.Write ("<TD><B>Program Name</B></TD>")
 Response.Write ("<TD WIDTH='80'><B>Downloads</B></TD>")
 Response.Write ("</TR>")
FOR I = 1 TO 10
SET RS = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, adoCon
IF RS.EOF THEN
ELSE
IF RS("Approved") = True THEN
 Response.Write ("<TR CLASS='BGColor02'>")
 Response.Write ("<TD VALIGN='Top'><A HREF='fldetails.asp?ID=" & RS("ID") & "'>" & RS("ProgramName") & "</A></TD>")
 Response.Write ("<TD WIDTH='80' VALIGN='Top'>" & RS("Downloads") & "</TD>")
 Response.Write ("</TR>")
END IF
RS.MoveNext
END IF

NEXT
 Response.Write ("</TABLE><BR>")
 Response.Write ("</TD></TR></TABLE>")
rs.Close
 Set rs = Nothing
%>

 



Posted By: Scotty32
Date Posted: 25 July 2003 at 5:26am

ummm well i dont have a clue then  sorry

but have you closed off the connection?

(ie conn.close etc)

looks like you only did the Record Set

oh and you could try "if NOT rs.eof then" to maybe cut out a lil code? (yay 1 line :P)

umm i dunno, id have a lil play with it if i was you, like put the part that doesnt work into a temp page, and test it on its own

you'll have less code, so wont get lost, and it could stand out easier



Posted By: Badaboem
Date Posted: 25 July 2003 at 6:06am

I have closed the connections...

rs.Close
 Set rs = Nothing



Posted By: Scotty32
Date Posted: 25 July 2003 at 6:28am

but dont you have to close the connection to the database AND the recordset?

you've only closed the recordset off

rs.Close
 Set rs = Nothing
conn.Close
 Set conn = Nothing

like that?



Posted By: Badaboem
Date Posted: 25 July 2003 at 6:45am
conn is not set as a connection string or anything else..if I put that int he script it says 'object required'


Posted By: Scotty32
Date Posted: 25 July 2003 at 6:51am

yeah but you have to close wot it says in the common.asp file right?

i thought you had to close all objects?



Posted By: Badaboem
Date Posted: 25 July 2003 at 6:54am

set conn isn't in the common.asp file either, so no ''conn'' to close here

This integration is driving me nuts..



Posted By: Scotty32
Date Posted: 25 July 2003 at 6:56am

lol you dont have to use the common.asp file to merge it with the forum

you can open your own database connections up cant you?

so yo can use the forum database, but you dont have to have the common.asp file in?

would fix your problem



Posted By: Badaboem
Date Posted: 25 July 2003 at 7:00am

yes, indeed...but if someone else is using the mod, it would be very nice if you can just change the database path in the common.asp file instead of every module you will install for webwiz forums..

That's what I'm after...so how would you rewrite the script so it uses common.asp?

It already works with the forum database...i just want it 2 work with common.asp for easy configuration.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net