Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - using common.asp connection
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

using common.asp connection

 Post Reply Post Reply Page  12>
Author
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post Topic: using common.asp connection
    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

Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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?

Back to Top
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2003 at 5:02am

you can see the script at work here: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
%>



Edited by Badaboem
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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
%>

Back to Top
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post 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

<!--#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
%>

 



Edited by Badaboem
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2003 at 6:06am

I have closed the connections...

rs.Close
 Set rs = Nothing

Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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?

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.