Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: SQL script with variable


Message #1 by "Graham Abrey" <design@t...> on Sun, 7 Apr 2002 00:30:17
Hi all,
Stupid question here but I am trying to use this SQL script which work 
fine if I use ' with the stated value ie 'UK' but this value changes all 
the time, so I wanted it to a variable.
The script below work with the stated value in it 'UK'

"SELECT AreaID, Region, Area FROM RegionAreaList " & _
                           "WHERE Region LIKE 'UK' "

But when I replace it with a variable (RegionAreaList), removing the ' it 
gives me an error because it can not recognise the line as a parameter.

"SELECT AreaID, Region, Area FROM RegionAreaList " & _
                           "WHERE Region LIKE SelectedArea "

Error:
Error Type:
Microsoft JET Database Engine (0x80040E10)
No value given for one or more required parameters.
/guest/viewjobs3.asp, line 58

I'm sure that the problem is simple to sort out but I have tried various 
ways. Is there anyway around the problem? Anyone any ideas?

Thanks
Graham
Message #2 by "Ethan Selzer" <ethanselzer@a...> on Sat, 6 Apr 2002 19:05:13 -0800
Hi Graham,

Give this a try.

"SELECT AreaID, Region, Area FROM RegionAreaList " & _
                           "WHERE Region LIKE  '%" & SelectedArea & "%' "

Ethan

-----Original Message-----
From: Graham Abrey [mailto:design@t...]
Sent: Sunday, April 07, 2002 12:30 AM
To: Access ASP
Subject: [access_asp] SQL script with variable

Hi all,
Stupid question here but I am trying to use this SQL script which work
fine if I use ' with the stated value ie 'UK' but this value changes all
the time, so I wanted it to a variable.
The script below work with the stated value in it 'UK'

"SELECT AreaID, Region, Area FROM RegionAreaList " & _
                           "WHERE Region LIKE 'UK' "

But when I replace it with a variable (RegionAreaList), removing the ' it
gives me an error because it can not recognise the line as a parameter.

"SELECT AreaID, Region, Area FROM RegionAreaList " & _
                           "WHERE Region LIKE SelectedArea "

Error:
Error Type:
Microsoft JET Database Engine (0x80040E10)
No value given for one or more required parameters.
/guest/viewjobs3.asp, line 58

I'm sure that the problem is simple to sort out but I have tried various
ways. Is there anyway around the problem? Anyone any ideas?

Thanks
Graham

Message #3 by "Graham Abrey" <design@t...> on Sun, 7 Apr 2002 10:40:29
Hi Ethan,
Thank, it worked. I suppose by taking out the % (wildcards) it will reduce 
the search choices.
Thanks Again,
Graham


> Hi Graham,

Give this a try.

"SELECT AreaID, Region, Area FROM RegionAreaList " & _
                           "WHERE Region LIKE  '%" & SelectedArea & "%' "

Ethan

-----Original Message-----
From: Graham Abrey [mailto:design@t...]
Sent: Sunday, April 07, 2002 12:30 AM
To: Access ASP
Subject: [access_asp] SQL script with variable

Hi all,
Stupid question here but I am trying to use this SQL script which work
fine if I use ' with the stated value ie 'UK' but this value changes all
the time, so I wanted it to a variable.
The script below work with the stated value in it 'UK'

"SELECT AreaID, Region, Area FROM RegionAreaList " & _
                           "WHERE Region LIKE 'UK' "

But when I replace it with a variable (RegionAreaList), removing the ' it
gives me an error because it can not recognise the line as a parameter.

"SELECT AreaID, Region, Area FROM RegionAreaList " & _
                           "WHERE Region LIKE SelectedArea "

Error:
Error Type:
Microsoft JET Database Engine (0x80040E10)
No value given for one or more required parameters.
/guest/viewjobs3.asp, line 58

I'm sure that the problem is simple to sort out but I have tried various
ways. Is there anyway around the problem? Anyone any ideas?

Thanks
Graham


  Return to Index