ASP question

He has: 18 posts

Joined: Jul 2005

I am using the following line of code to pull information from a SQL database. It worked perfectly untill my OS partition was corrupted. The database is intact, but the code no longer pulls the data. Any advice would be welcome. MS Server 2003, SQL 2000 SP 3a.

Here is the entire script from the page, if any of you see anything wrong with it, please let me know

<?php
Option Explicit
Dim StoryID
Dim dcnDB
Dim strSQL
Dim rsfeature
Dim rsmedia
Dim rsLeadership
Dim rsMilitary
Dim rsExternal
Dim rsCommunications
Dim rsRight
Dim rsHeadline
Dim rsTop
Dim rsFooter
Dim rsPhoto
Dim rsStory
Dim ID
Dim rsNewcomers


IF Session ("Banner") = "" Then
Response
.Redirect("security.asp")
End IF

StoryID = Request.QueryString("StoryID")

Set dcnDB = Server.CreateObject("ADODB.Connection")
dcnDB.open "PROVIDER=SQLOLEDB;DATA SOURCE=cfc-webserver2;DATABASE=cfcPublicSite"

strSQL = "SELECT * FROM Links " _
& "WHERE Feature = 1 " _
& "ORDER BY LinkPriority"
Set rsfeature = dcnDB.Execute(strSQL)

strSQL = "SELECT * FROM Links " _
& "WHERE media = 1 " _
& "ORDER BY LinkPriority"
Set rsmedia = dcnDB.Execute(strSQL)

strSQL = "SELECT * FROM Links " _
& "WHERE Newcomers = 1 " _
& "ORDER BY LinkPriority"
Set rsNewcomers = dcnDB.Execute(strSQL)

strSQL = "SELECT * FROM Links " _
& "WHERE Leadership = 1 " _
& "ORDER BY LinkPriority"
Set rsLeadership = dcnDB.Execute(strSQL)

strSQL = "SELECT * FROM Links " _
& "WHERE Military = 1 " _
& "ORDER BY LinkPriority"
Set rsMilitary = dcnDB.Execute(strSQL)

strSQL = "SELECT * FROM Links " _
& "WHERE External = 1 " _
& "ORDER BY LinkPriority"
Set rsExternal = dcnDB.Execute(strSQL)

strSQL = "SELECT * FROM Links " _
& "WHERE Communications = 1 " _
& "ORDER BY LinkPriority"
Set rsCommunications = dcnDB.Execute(strSQL)

strSQL = "SELECT TOP 10 * FROM Stories " _
& "WHERE Headline = 0 " _
& "ORDER BY StoryID DESC"
Set rsRight = dcnDB.Execute(strSQL)

strSQL = "SELECT * FROM Links " _
& "WHERE Footer = 1 " _
& "ORDER BY LinkPriority"
Set rsFooter = dcnDB.Execute(strSQL)

strSQL = "SELECT * FROM Links " _
& "WHERE Header = 1 " _
& "ORDER BY LinkPriority"
Set rsTop = dcnDB.Execute(strSQL)

If
StoryID = "" Then
strSQL
= "SELECT * FROM Stories " _
& "WHERE Headline = 1 " _
& "ORDER BY StoryID DESC"
Set rsHeadline = dcnDB.Execute(strSQL)

ID = rsHeadline("StoryID")

strSQL = "SELECT Top 2 * FROM Photos " _
& "WHERE StoryID = " & ID
Set rsPhoto
= dcnDB.Execute(strSQL)

Else

strSQL = "SELECT * FROM Stories " _
& "WHERE StoryID = " _
& StoryID _
& "ORDER BY StoryID DESC"
Set rsStory = dcnDB.Execute(strSQL)

strSQL = "SELECT Top 2 * FROM Photos " _
& "WHERE StoryID = " & StoryID
Set rsPhoto
= dcnDB.Execute(strSQL)
End If
?>

They have: 5,633 posts

Joined: Jan 1970

The proublem proubaly isn't in the code its self. Maybe the connection string? Have you restored the old user name/password/tables/colum names?

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

What's the error you get when you try and run this? Nothing immediately jumps-out at me as being wrong here...

Although as bja says SQL Server in particular can behave very strangely if your user hasn't got the permissions required.

a Padded Cell our articles site!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.