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 25th, 2005, 10:54 AM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default strSQL syntax

Dear All,

The debugger finds a syntax error in the following SQL statement:

Dim strSQL as string = "SELECT TrajectCodeID FROM TrajectCode" & _
"WHERE CLng(SelectedSoftwareFilter) = TrajectCode.SoftwareID" & _
" AND " & Cstr(SelectedKnowledgeFilter)&" =TrajectCode.VoorkennisID"&_
"AND "& Cstr(SelectedCompetenceFilter)&"=TrajectCode.Compe tentieID"

This statement queries a Database where all colomns are of type Long. The query result is intented to populate a DataGrid. SelectedKnowledgeFilter is a variable of type integer. It is used in a case statement to convert a seleted string from a combo box and assign it an integer value. The SQL error message says that my syntax is wrong after the FROM key-word.

Can someone help?
By the way, thanks to Imar who has given me a good tip on my previous posting. Problem solved, Imar. Thanks.
Christiane

 
Old January 25th, 2005, 11:05 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Dim strSQL as string = "SELECT TrajectCodeID FROM TrajectCode " & _
"WHERE " & CLng(SelectedSoftwareFilter) & " = TrajectCode.SoftwareID " & _
"AND " & Cstr(SelectedKnowledgeFilter) & " = TrajectCode.VoorkennisID " & _
"AND " & Cstr(SelectedCompetenceFilter) & " = TrajectCode.CompetentieID"

Are these variables Cstr(SelectedCompetenceFilter), Cstr(SelectedKnowledgeFilter) text fields? If so you need single quotes.

AND TrajectCode.SoftwareID = '" & Cstr(SelectedKnowledgeFilter)& "'



 
Old January 25th, 2005, 11:06 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

By the look of it, you need a space after "TrajectCode", as when built the string will contain "TrajectCodeWHERE". Space also required after TrajectCode.VoorkennisID

HTH,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
response.write strSQL shows no values! ronny Classic ASP Databases 3 December 13th, 2007 01:50 PM
Chapter 2 strSQL statement tomyeager BOOK: Beginning VB.NET Databases 4 September 22nd, 2007 10:16 AM
Strange Error inh STRSQL alirezaaali Classic ASP Databases 1 August 5th, 2007 11:56 AM
help syntax please khautinh SQL Server 2000 1 August 26th, 2006 02:47 AM
Strsql setyna Access 4 June 29th, 2004 08:11 AM





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