Print Page | Close Window

strSQL Error

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=4270
Printed Date: 30 March 2026 at 6:55am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: strSQL Error
Posted By: Pegaso
Subject: strSQL Error
Date Posted: 15 July 2003 at 4:23pm

I'm working on my new site and I have the following problem:

  • i have the Access file, that contains the tables, tblClassment and tblPoints, etc.
  • now in Access i can relate the 2 tables with a very simple Query, and I can go in the SQL view and copy the following SQL Code:

    SELECT tblClassment.Pilot_ID, Sum(tblPoints.Points) AS SommaDiPoints
    FROM tblPoints RIGHT JOIN tblClassment ON tblPoints.Position = tblClassment.Position_Pilot
    GROUP BY tblClassment.Pilot_ID;
  • in Access this query works very good but when i copy the code in ASP and I edit it, it didn't work and the ASP site give me an "Unspecified error". The ASP Code is the following:

    <%
        Dim rsClassment
        Set rsClassment = Server.CreateObject("ADODB.Recordset")
        strSQL = "SELECT DISTINCT tblClassment.Pilot_ID, Sum(tblPoints.Points) AS SommaDiPoints"
        strSQL = strSQL & " FROM tblPoints RIGHT JOIN tblClassment ON tblPoints.Position = tblClassment.Position_Pilot"
        strSQL = strSQL & "GROUP BY tblClassment.Pilot_ID;"
        rsClassment.Open strSQL, adoCon
         %>

Can anyone help my to solve this problem. Where is the error??

Thank's to all.



-------------



Replies:
Posted By: ljamal
Date Posted: 15 July 2003 at 5:32pm
maybe the spacing in this line
strSQL = strSQL & "GROUP BY tblClassment.Pilot_ID;"
should be
strSQL = strSQL & " GROUP BY tblClassment.Pilot_ID;"
with a space before GROUP

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: Pegaso
Date Posted: 15 July 2003 at 10:45pm

No, thats not the problem .

Thanks



-------------


Posted By: Bunce
Date Posted: 16 July 2003 at 7:17am
Originally posted by Pegaso Pegaso wrote:

No, thats not the problem .

Thanks

Well, yes it is a problem as there is NO space before the keyword in the code you've pasted.

However, you've also added the DISTINCT keyword to your strSQL so its not the same as your initial query anyway.

If it is working in your query, why not just excute the query from ASP, rather than copying the SQL out?

Cheers,
Andrew



-------------
There have been many, many posts made throughout the world...
This was one of them.


Posted By: ljamal
Date Posted: 16 July 2003 at 8:07am
didn't even notice the distinct.
place the field following the distinct in parentheses and you may need to the include the sum that you are returning in the group by statement as well.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming



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