SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 29th, 2005, 12:44 PM
Buckers Buckers is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 36 Buckers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 12 m 57 sec
Reputation Power: 6
Where clause not working

Hi

I'm using asp and an Access database to create a combo box sourced from an Access Table to update another Access Table. The drop down data is to be controlled by a value on the page and the initial part of the code is as follows:

<%
Dim objConnection
Dim objRecordset

Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.Open "DSN=TilesW"

Set objRecordset = Server.CreateObject("ADODB.Recordset")

Dim strSQL
strSQL = "SELECT RangeRef, ID, Available FROM OnSite "& _
"WHERE RangeRef = 'form.RangeID.value'; "

objRecordset.Open strSQL, objConnection
%>

The where statement seems to be the problem because if I replace it with a real RangeID value as below everything works fine.

"WHERE RangeRef = 2; "

I'm not sure if it is to do with quotes, single quotes, spaces, etc, etc, but I've tried numerous variations ang get all messages including "mismatch in criteria expression" for the version above.

I'm quite new to this and would appreciate some help please.

Thanks in advance
David

Reply With Quote
  #2  
Old March 29th, 2005, 12:47 PM
mehere's Avatar
mehere mehere is offline
Senior Sarcasm Wizardess
ASP Free God 16th Plane (12500 - 12999 posts)
 
Join Date: Feb 2005
Location: Dreamland
Posts: 12,870 mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 10976 Folding Title: Novice Folder
Time spent in forums: 4 Months 4 Weeks 17 h 13 m 19 sec
Reputation Power: 1762
Quote:
Originally Posted by Buckers
Hi

I'm using asp and an Access database to create a combo box sourced from an Access Table to update another Access Table. The drop down data is to be controlled by a value on the page and the initial part of the code is as follows:

strSQL = "SELECT RangeRef, ID, Available FROM OnSite "& _
"WHERE RangeRef = & form.RangeID.value



Make the above change in red if this a number field. If it is a text field use: = '" & form.RangeID.value & "'"

Reply With Quote
  #3  
Old March 30th, 2005, 03:57 AM
Buckers Buckers is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 36 Buckers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 12 m 57 sec
Reputation Power: 6
Quote:
Originally Posted by mehere
Make the above change in red if this a number field. If it is a text field use: = '" & form.RangeID.value & "'"


Hi

It is a number field. I get the following message using the number option:
Syntax error (missing operator) in query expression 'RangeRef = & form.RangeID.value'.

And the following using the text option:
Expected end of statement
/TileLibrary/pages/html/updates.asp, line 312, column 47
"WHERE RangeRef = '" & form.RangeID.value & "'"; "
----------------------------------------------^

Thanks

Reply With Quote
  #4  
Old March 30th, 2005, 06:18 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
Hi,

if its a number field, use this query, should be able to just copy and paste it


Code:
strSQL = "SELECT RangeRef, ID, Available FROM OnSite " &_
 "WHERE RangeRef = " & form.RangeID.value


hope this helps
__________________
Look! Its a ShemZilla



Last edited by nofriends : March 30th, 2005 at 06:21 AM.

Reply With Quote
  #5  
Old March 30th, 2005, 10:28 AM
Buckers Buckers is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 36 Buckers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 12 m 57 sec
Reputation Power: 6
Thanks, but error message:

Expected end of statement
/TileLibrary/pages/html/updates.asp, line 345, column 40
"WHERE RangeRef = " & form.RangeID.value; "

Reply With Quote
  #6  
Old March 30th, 2005, 10:32 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,879 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 18 h
Reputation Power: 500
Try
Code:
strSQL = "SELECT RangeRef, ID, Available FROM OnSite WHERE RangeRef = " & form.RangeID.value

Reply With Quote
  #7  
Old March 31st, 2005, 03:14 AM
Buckers Buckers is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 36 Buckers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 12 m 57 sec
Reputation Power: 6
Quote:
Originally Posted by Memnoch
Try
Code:
strSQL = "SELECT RangeRef, ID, Available FROM OnSite WHERE RangeRef = " & form.RangeID.value



Thanks. Tried that, message below:
Expected end of statement
/TileLibrary/pages/html/updates.asp, line 345, column 40
"WHERE RangeRef = " & form.RangeID.value; "

Reply With Quote
  #8  
Old March 31st, 2005, 03:23 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
Hi,

Memnoch's query is correct, copy and paste the query and leave the ; " at the end of the strSQL, that is where your problem is
Code:
 "WHERE RangeRef = " & form.RangeID.value; "

hope this helps

Reply With Quote
  #9  
Old March 31st, 2005, 03:31 AM
Buckers Buckers is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 36 Buckers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 12 m 57 sec
Reputation Power: 6
I did leave the ; " at the end, but get the same message:
Expected end of statement
/TileLibrary/pages/html/updates.asp, line 345, column 40
"WHERE RangeRef = " & form.RangeID.value; "

Reply With Quote
  #10  
Old March 31st, 2005, 03:54 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
ok

do a response.write strSQL, and response.end
after this line and post the result here

Code:
strSQL = "SELECT RangeRef, ID, Available FROM OnSite WHERE RangeRef = " & form.RangeID.value
'---->
response.write strSQL
response.end

Reply With Quote
  #11  
Old March 31st, 2005, 04:52 AM
Buckers Buckers is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 36 Buckers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 12 m 57 sec
Reputation Power: 6
Quote:
Originally Posted by nofriends
ok

do a response.write strSQL, and response.end
after this line and post the result here

Code:
strSQL = "SELECT RangeRef, ID, Available FROM OnSite WHERE RangeRef = " & form.RangeID.value
'---->
response.write strSQL
response.end



Put code like this:
strSQL = "SELECT RangeRef, ID, Available FROM OnSite "& _
"WHERE RangeRef = " & form.RangeID.value; "
response.write strSQL
response.end

The page doesn't display so there is no result, just the error message as before;
Expected end of statement
/TileLibrary/pages/html/updates.asp, line 345, column 40
"WHERE RangeRef = " & form.RangeID.value; "

Am I misunderstanding you.

Reply With Quote
  #12  
Old March 31st, 2005, 05:04 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
Quote:
Originally Posted by Buckers
Put code like this:
strSQL = "SELECT RangeRef, ID, Available FROM OnSite "& _
"WHERE RangeRef = " & form.RangeID.value; "
response.write strSQL
response.end


did you copy and paste this code here?

the ;" must NOT be there, that is what is causing the error.

hope this helps

Reply With Quote
  #13  
Old March 31st, 2005, 05:11 AM
Buckers Buckers is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 36 Buckers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 12 m 57 sec
Reputation Power: 6
Quote:
Originally Posted by nofriends
did you copy and paste this code here?

the ;" must NOT be there, that is what is causing the error.

hope this helps



OK. Code looks like this:
strSQL = "SELECT RangeRef, ID, Available FROM OnSite "& _
"WHERE RangeRef = " & form.RangeID.value
response.write strSQL
response.end

Message:
Object required: ''
/TileLibrary/pages/html/updates.asp, line 344

Thanks

Reply With Quote