ACC2000: Syntax Error When You Export a Parameter Query to Active Server Page (ASP) Format (243834)
The information in this article applies to:
This article was previously published under Q243834 Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies only to a Microsoft Access database (.mdb).
SYMPTOMS
When you export a Microsoft Access parameter query in the Active Server Page (ASP) format and then view the ASP page from a browser, you may receive an error message similar to the following:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '((([Customers].[CustomerID])=stomer ID]))'.
/test/qryAsp.ASP, line 22
where the expected syntax would have been:
((([Customers].[CustomerID])=[Enter Customer ID]))
CAUSE
When the query is saved to ASP, two files are generated: one in ASP format, the other in HTML format. The parameter is written to both, but in the ASP file, the parameter portion that references Request.QueryString has been incorrectly parsed.
Further, if the query is re-exported to the same name, Access requests to overwrite the ASP file, but does not overwrite the HTML file. This results in a mismatch with Request.QueryString.
For example, in a query that is based on the Customer table in the sample database Northwind.mdb, the SQL statement might read:
SELECT Customers.CompanyName, Customers.ContactName
FROM Customers
WHERE (((Customers.CustomerID)=[Enter Customer ID]));
When you export the query to ASP format, the syntax becomes:
"SELECT Customers.CompanyName, Customers.ContactName
FROM Customers
WHERE (((Customers.CustomerID)=" & Request.QueryString("[Enter Cu") & "stomer ID])) "
RESOLUTION
To get the correct result, use Notepad or an HTML editor to correct the syntax. For example, in the "Steps to Reproduce the Behavior" section later in this article, the following syntax is generated when the query is exported:
sql = "SELECT Customers.CompanyName, Customers.ContactName
FROM Customers
WHERE (((Customers.CustomerID)=" & Request.QueryString("[Enter Cu") & _
"stomer ID])) "
Edit the SQL statement to read as follows:
sql = "SELECT [Customers].[CustomerID], [Customers].[CompanyName], _
[Customers].[ContactName]
FROM Customers
WHERE ((([Customers].[CustomerID])='" & _
Request.QueryString("[Enter CustomerID]") & "'))"
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 7/14/2004 |
---|
Keywords: | kbbug kberrmsg kbpending KB243834 |
---|
|