Problem passing empty form fields to access parameter query
- From: bjornkamlin@xxxxxxxxxxxxxx
- Date: 29 Jan 2007 12:39:22 -0800
I have seen a lot of good discussions concerning parameter queries in
Access2000 and how to pass parameters from forms in ASP. I have tried
many of the solutions but I can't get my application to work.
I hope that someone can straight out my problems below.
I have the following query in Access 2000;
SELECT measure.txt_measurement, measure.nr_value AS [value]
FROM measure
WHERE (((measure.txt_measurement) Like "*" & [measure] & "*") AND
((measure.nr_value)>[param_minvalue])) OR ((([measure]) Is Null) AND
(([param_minvalue]) Is Null));
The query should return all records if the parameters are empty.This
works fine in Access.
I send the parameters from an ASP form page and want to return the
recordset with the following code
<%
dim measure
measure = ""
if Request("measurement")<>"" then measure = Request("measurement")
dim param_minvalue
param_minvalue = ""
if Request("minvalue")<>"" then param_minvalue = Request("minvalue")
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_market_STRING
Command1.CommandText = "query_test_parameter '" & measure & "', " &
param_minvalue
Command1.CommandType = 4
Command1.CommandTimeout = 0
Command1.Prepared = true
set bktst = Command1.Execute
bktst_numRows = 0
%>
Of course other code comes after this, but I assume this part is what
is doing the job.
-------The problem-----------
When I try to run the ASP-page, I get the following error.
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in parameters
clause. Make sure the parameter exists and that you typed its value
correctly.
However, if I change the row of
param_minvalue = ""
to
param_minvalue = "0"
or make sure that the number parameter contains any number, the
parameters are passed correctly and runs properly.
Obviously the param_minvalue "get lost" on the way, and is not
delivered as Null to the database.
What am I doing wrong?
Bjorn
.
- Follow-Ups:
- Re: Problem passing empty form fields to access parameter query
- From: Mike Brind
- Re: Problem passing empty form fields to access parameter query
- Prev by Date: Re: ASP.Net - Displaying DB Records
- Next by Date: Re: Problem passing empty form fields to access parameter query
- Previous by thread: ASP.Net - Displaying DB Records
- Next by thread: Re: Problem passing empty form fields to access parameter query
- Index(es):
Relevant Pages
|
Loading