Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 15th, 2007, 02:54 PM
Registered User
 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Recordset Error Message

I am getting the following error message when I execute my asp page:

Microsoft OLE DB Provider for SQL Server (0x80040E14)
Incorrect syntax near '11'.
/expertcs/Forum/index.asp, line 27

This error is referencing my new recordset, here is the code:


<%
Dim rsPost__MMColParam
rsPost__MMColParam = "1"
If (Request("MM_EmptyValue") <> "") Then
rsPost__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Dim rsPost__MMColParam2
rsPost__MMColParam2 = "1/14/2007"
If (Now() - 7 <> "") Then
rsPost__MMColParam2 = Now() - 7
End If
%>
<%
Dim rsPost
Dim rsPost_numRows

Set rsPost = Server.CreateObject("ADODB.Recordset")
rsPost.ActiveConnection = MM_connExpertCS_STRING
rsPost.Source = "SELECT intPostID, txtPostTitle, dtePostDate, intPostBy, intCatID, memPostContent, txtNickName FROM dbo.tbl_Blog, dbo.tbl_Users WHERE bitPostShow = " + Replace(rsPost__MMColParam, "'", "''") + " AND dbo.tbl_Blog.intPostBy = dbo.tbl_Users.intUserID AND dtePostDate > " + Replace(rsPost__MMColParam2, "'", "''") + " ORDER BY dtePostDate DESC"
rsPost.CursorType = 0
rsPost.CursorLocation = 2
rsPost.LockType = 1
rsPost.Open() <-- This is the line 27 that the error message is referring too.

rsPost_numRows = 0
%>

Can anyone tell me why I am getting an error for my rsPost function?
 
Old January 15th, 2007, 04:25 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Most probably, your SQL Command is incorrect, double check it.

-----------------------------------------------------------
I will only tell you how to do it, not do it for you.------------
Unless, of course, you want to hire me to do work for you.---
^^Thats my signature--------------------------------------
-----------------------------------------------------------
http://www.catb.org/~esr/faqs/smart-questions.html -------
^^Took that from planoie's profile--------------------------
-----------------------------------------------------------
 
Old January 15th, 2007, 04:48 PM
Registered User
 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I'm a student trying to learn asp... So if you are willing to tell me how to troubleshoot this problem, I am all ears...

I am in the process of building a blog and I only want to display posting that are 7 days old. In my recordset, I created a variable called MMCalParam to hold a default date value "1/14/2007". I was taught that whenever you declare date variables in Sql, you're suppose to presede and procede it with # signs. When I did that, dreamweaver threw an error message stating "Invalid syntex '#'".

So now that I've omitted the # signs, I was able to create my recordset. But when I tried to view the web page live, I got the error message stated above... Do you have any idea on what I can do to resolve this?

 
Old January 16th, 2007, 12:22 AM
Authorized User
 
Join Date: Jan 2007
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to saurabhj Send a message via Yahoo to saurabhj
Default

Try Following code to open your recordset:

Set rsPost = Server.CreateObject("ADODB.Recordset")
sSQL = "SELECT intPostID, txtPostTitle, dtePostDate, intPostBy, intCatID, memPostContent, txtNickName FROM dbo.tbl_Blog, dbo.tbl_Users WHERE bitPostShow = " + Replace(rsPost__MMColParam, "'", "''") + " AND dbo.tbl_Blog.intPostBy = dbo.tbl_Users.intUserID AND dtePostDate > " + Replace(rsPost__MMColParam2, "'", "''") + " ORDER BY dtePostDate DESC"

rsPost.Open sSQL,MM_connExpertCS_STRING,0,2,1


 
Old January 16th, 2007, 01:27 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hi,
replace with this, only your sql query.
still error, please send me the error back.
rsPost.Source = "SELECT intPostID, txtPostTitle, dtePostDate, intPostBy, intCatID, memPostContent, txtNickName FROM dbo.tbl_Blog, dbo.tbl_Users WHERE bitPostShow = '" Replace(rsPost__MMColParam, "'", "''") "' AND dbo.tbl_Blog.intPostBy = dbo.tbl_Users.intUserID AND dtePostDate > '" Replace(rsPost__MMColParam2, "'", "''") "' ORDER BY dtePostDate DESC"

surendran
(Anything is Possible)
http://ssuren.spaces.msn.com
 
Old January 16th, 2007, 04:47 AM
Authorized User
 
Join Date: Jan 2007
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to saurabhj Send a message via Yahoo to saurabhj
Default

Use JOIN in your SQL Query.

-Saurabh





Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the error message for a 500 server error? chobo2 C# 2005 1 May 4th, 2008 03:11 AM
Get the error "ADODB.Recordset error '800a0e7d' " Raymond Classic ASP Databases 2 August 5th, 2006 03:53 PM
Advance search recordset giving error message? yts007 Dreamweaver (all versions) 15 January 13th, 2006 01:54 AM
Recordset Error malhyp Dreamweaver (all versions) 3 December 21st, 2005 05:06 PM
Recordset error lance Access ASP 1 February 17th, 2004 07:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.