|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Cant limit records from an access database using request.querystring
Im creating an asp page for a simple website to recall records of past projects from an access database. The records within the database have images attached via a different table. Im using jscript to display the pictures, and trying to use Request.QueryString to try and only show the pictures of one project depending on the link clicked by the user. When trying to use Request.QueryString im shown an error:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10) [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. The line of code im trying to use is: strSQL = "SELECT Photo_FileName FROM ProjectPhoto WHERE ProjectPhoto.Photo_ProjectID = " + Request.QueryString; Any help or suggestions on this would be greatly appreciated |
|
#2
|
|||
|
|||
|
You should be using request.querystring("variablename_here"). When you call request.querystring without any qualifier, you get a comma-delimited string of all querystring stuff.
Also it's a bad idea to pass user input directly to a sql query without filtering it for hacks, etc. Copy request.querystring variable to a local variable, then validate it and finally use the validated data in your sql query.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
Better still, use the ado command object parameters collection.
See the MSDN docs for details. |
|
#4
|
|||
|
|||
|
Thanks guys, ive now fixed the problem, the querystring variable wasn't initialised properly, so there as nothing for the process to call, hence the expected parameter.
Thanks again |
|
#5
|
|||
|
|||
|
Quote:
If you left the code as-is it will: 1: break when you need to add another querystring variable 2: be wide open to sql injection attacks That is poorly written code: it behooves you to fix it, as described in this thread. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Cant limit records from an access database using request.querystring |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|