ASP Code - A quick challenge

I'm no good at ASP, a friend sent me this code which should allow me to display the latest posts from my forum on my front page; however I cannot get it to connect to my SQL server. Someone has told me that the problem might be in this bit - rsCommon.Open strSQL, adoCon however that might also be a red herring. I am getting the following error if I try and use this script;

Code:
Microsoft OLE DB Provider for SQL Server error '80040e14'

'Incorrect syntax near '.'.

/asp/mb/latestposts.asp, line 95

Note that there is general HTML before the script, so ignore the line 95 bit.

Here is the script;

Code:
<%
'#########################################################################
'##
'## Display Newest Forum Posts with WebWizForums v8.x
'##
'## Just configure the database settings and it will read the latest forum
'## posts. This file should be setup for your website.
'##
'## Mod from www.iportalx.net
'##
'## Writen by Drew Gauderman (aka MadDog)
'## Email: [email protected]
'## Website: www.iportalx.net
'##
'## Dont want to do this yourself? Get iPortalX! A Portal with WebWizForum!
'## http://www.iportalx.net
'##
'#########################################################################

Dim rsCommon
Dim adoCon
Dim strCon
Dim strSQL
Dim strLastestPostsModTopicSubject
Dim strLastestPostsModForumPath
Dim intLastestPostsTotal
Dim strDatabaseType
Dim strDBTrue
Dim strDBFalse
'The path to the forum
strForumPath = "/"
'How many new topics to show
intLastestPostsTotal = 25
'//-----------------------------------------------------
'// Database connection and settings
'//-----------------------------------------------------
'Database settings for Access
'strDatabaseType = "Access"
'strDBTrue = "True"
'strDBFalse = "False"
'Database settings for MSSQL
strDatabaseType = "SQLServer"
strDBTrue = "1"
strDBFalse = "0"
'Database settings for MySQL
'strDatabaseType = "MySQL"
'strDBFalse = 0
'strDBTrue = -1
'Access connection
'strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../forum")

'MSSQL Connection
'Const strSQLServerName = "snip" 'Holds the name of the SQL Server (This is the name/location or IP address of the 'SQL Server)
'Const strSQLDBUserName = "snip" 'Holds the user name (for SQL Server Authentication)
'Const strSQLDBPassword = "snip" 'Holds the password (for SQL Server Authentication)
'Const strSQLDBName = "snip"
'strCon = "Provider=SQLOLEDB;Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";"
'//-----------------------------------------------------
'Start the database connection
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open strCon
'Start a recordset connection
Set rsCommon = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT "
If strDatabaseType = "SQLServer" OR strDatabaseType = "Access" Then strSQL = strSQL & " TOP " & intLastestPostsTotal & " "
strSQL = strSQL & "tblForum.Forum_name, tblTopic.Topic_ID, tblTopic.Subject, tblThread.Thread_ID, tblThread.Message_date, tblAuthor.Author_ID, tblAuthor.Username, tblThread.Message  " & _
"FROM tblForum, tblTopic, tblAuthor, tblThread, tblPermissions" & _
"WHERE tblForum.Forum_ID = tblTopic.Forum_ID " & _
"AND tblTopic.Topic_ID = tblThread.Topic_ID " & _
"AND tblAuthor.Author_ID = tblThread.Author_ID " & _
"AND tblForum.Forum_ID = tblPermissions.Forum_ID " & _
"AND (tblPermissions.Group_ID = 2 AND tblPermissions.View_Forum = " & strDBTrue & ") "
strSQL = strSQL & "AND (tblForum.Password = '' OR tblForum.Password Is Null) AND (tblTopic.Hide = " & strDBFalse & " AND tblThread.Hide = " & strDBFalse & ") ORDER BY tblThread.Message_date DESC "
'mySQL limit operator
If strDatabaseType = "mySQL" Then strSQL = strSQL & " LIMIT " & intLastestPostsTotal
strSQL = strSQL & ";"
rsCommon.Open strSQL, adoCon
If NOT rsCommon.EOF Then saryForumPosts = rsCommon.getRows()
'Close all connections, very important!!
rsCommon.Close
Set rsCommon = Nothing
adoCon.Close
Set adoCon = Nothing
 
'No forum posts
If IsArray(saryForumPosts) = False Then
Response.Write "<span class=""text_arial"">No Forum Posts Made</span>"
'Forum posts have been made
Else
'Loop through the array of forum posts
For intLoopCounter = 0 TO UBound(saryForumPosts, 2)
'saryForumPosts array lookup table
'0 = tblForum.Forum_name
'1 = tblTopic.Topic_ID
'2 = tblTopic.Subject
'3 = tblThread.Thread_ID
'4 = tblThread.Message_date
'5 = tblAuthor.Author_ID
'6 = tblAuthor.Username
'7 = tblThread.Message
strLastestPostsModTopicSubject = saryForumPosts(2, intLoopCounter)
'Crop the subject down to 18 characters
If Len(strLastestPostsModTopicSubject) > 18 then strLastestPostsModTopicSubject = Left(strLastestPostsModTopicSubject,30) & "..."
Response.Write("<a href=""" & strForumPath & "forum_posts.asp?TID=" & saryForumPosts(1, intLoopCounter) & """>" & strLastestPostsModTopicSubject & "</a><br />")
Next
End If
%>

Thank you for any help!:
 
are you sure the adoCon connection has been opened already?
dont forget to include the #includes in the file.

otherwise take it to the support forums as listed in the intro to the file.
 
are you sure the adoCon connection has been opened already?
dont forget to include the #includes in the file.

otherwise take it to the support forums as listed in the intro to the file.

I have made a post on their support forums as well, unfortunetly its only a small site and they don't seem to respond to posts very often. Plus it keeps going offline.

How would I tell if the adoCon Connection was already open?

There was no "includes" file with this script, should there be?
 
webwizguide.info has a very very active forum and i'll bet you can get any answers you need just by searching their forums.
 
Back
Top