I try to run the following SQL statement to get the count, but I get this error. I can’t seem to see what is the problem. Maybe I am working on this way too long to see the obvious. Thank you!!!
This is the error message that I get:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
Here is my code:
<%
Option Explicit
Dim strConnect
%>
<!-- METADATA TYPE = "typelib" FILE = "C:\Program Files\Common Files\System\ado\msado15.dll" -->
<html>
<head>
<title> Query the database </title>
</head>
<body>
<%
Dim strSQL, intNumber, objConn
strConnect = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/database/report.mdb"
&";" &_
"Persist Security Info = False"
Set objConn = Server.CreateObject("ADODB.Connection"
objConn.open strConnect
strSQL= "SELECT Count(tblSurveyRawData.Q35A) AS CountOfQ35A" & _
"FROM tblRep INNER JOIN tblSurveyRawData ON tblRep.Rep_ID = tblSurveyRawData.Rep_ID" & _
"WHERE tblSurveyRawData.[MONTH/YEAR] Between '" & Request.Form("BeginQrtDate"
& "' And '" & Request.Form("EndQrtDate"
& "') " & _
"AND (tblRep.RepLeaderID = '" & Request.Form("RepLeaderID"
& "') AND (tblSurveyRawData.Q35A = '9' Or tblSurveyRawData.Q35A = '10'))"
intNumber = objConn.Execute strSQL
Set objConn = Nothing
Response.write intNumber & "<BR>"
%>
</BODY>
</HTML>
This is the error message that I get:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
Here is my code:
<%
Option Explicit
Dim strConnect
%>
<!-- METADATA TYPE = "typelib" FILE = "C:\Program Files\Common Files\System\ado\msado15.dll" -->
<html>
<head>
<title> Query the database </title>
</head>
<body>
<%
Dim strSQL, intNumber, objConn
strConnect = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/database/report.mdb"
"Persist Security Info = False"
Set objConn = Server.CreateObject("ADODB.Connection"
objConn.open strConnect
strSQL= "SELECT Count(tblSurveyRawData.Q35A) AS CountOfQ35A" & _
"FROM tblRep INNER JOIN tblSurveyRawData ON tblRep.Rep_ID = tblSurveyRawData.Rep_ID" & _
"WHERE tblSurveyRawData.[MONTH/YEAR] Between '" & Request.Form("BeginQrtDate"
"AND (tblRep.RepLeaderID = '" & Request.Form("RepLeaderID"
intNumber = objConn.Execute strSQL
Set objConn = Nothing
Response.write intNumber & "<BR>"
%>
</BODY>
</HTML>