Hi,
I'm new to ASP and have stumbled across what appears to be a common
problem, but after trying several solutions from other posts I've had
no luck. My SQL SELECT statement is fine elsewhere (e.g. in ACCESS),
but when executed from ASP I get this syntax error:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect
syntax near '16'.
/forecast/test.asp, line 27
(line 27 is where the date is in the HAVING part of the statement)
Here is the Statement:
----------------------
SELECT dbo_ForecastIn. DataTime AS E_Time, dbo_ForecastInD ata.DataTime
AS FD_Time, dbo_ForecastInD ata.WindFarmPow er AS ForecastPower FROM
dbo_ForecastIn INNER JOIN dbo_ForecastInD ata ON dbo_ForecastIn. DataID
= dbo_ForecastInD ata.DataID GROUP BY dbo_ForecastIn. DataTime,
dbo_ForecastInD ata.DataTime, dbo_ForecastInD ata.WindFarmPow er HAVING
dbo_ForecastIn. DataTime = #06/02/2004 16:00:00# ORDER BY
dbo_ForecastIn. DataTime, dbo_ForecastInD ata.DataTime;
Here is the code:
-----------------
SQLStmt = "SELECT dbo_ForecastIn. DataTime AS E_Time,
dbo_ForecastInD ata.DataTime AS FD_Time,
dbo_ForecastInD ata.WindFarmPow er AS ForecastPower "
SQLStmt = SQLStmt & "FROM dbo_ForecastIn INNER JOIN
dbo_ForecastInD ata ON dbo_ForecastIn. DataID =
dbo_ForecastInD ata.DataID "
SQLStmt = SQLStmt & "GROUP BY dbo_ForecastIn. DataTime,
dbo_ForecastInD ata.DataTime, dbo_ForecastInD ata.WindFarmPow er "
SQLStmt = SQLStmt & "HAVING dbo_ForecastIn. DataTime = #06/02/2004
16:00:00# "
SQLStmt = SQLStmt & "ORDER BY dbo_ForecastIn. DataTime,
dbo_ForecastInD ata.DataTime;"
response.write( SQLStmt)
Set RS = Connection.Exec ute(SQLStmt)
Hope one of you geniuses can sort me out.
Thanks.
I'm new to ASP and have stumbled across what appears to be a common
problem, but after trying several solutions from other posts I've had
no luck. My SQL SELECT statement is fine elsewhere (e.g. in ACCESS),
but when executed from ASP I get this syntax error:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect
syntax near '16'.
/forecast/test.asp, line 27
(line 27 is where the date is in the HAVING part of the statement)
Here is the Statement:
----------------------
SELECT dbo_ForecastIn. DataTime AS E_Time, dbo_ForecastInD ata.DataTime
AS FD_Time, dbo_ForecastInD ata.WindFarmPow er AS ForecastPower FROM
dbo_ForecastIn INNER JOIN dbo_ForecastInD ata ON dbo_ForecastIn. DataID
= dbo_ForecastInD ata.DataID GROUP BY dbo_ForecastIn. DataTime,
dbo_ForecastInD ata.DataTime, dbo_ForecastInD ata.WindFarmPow er HAVING
dbo_ForecastIn. DataTime = #06/02/2004 16:00:00# ORDER BY
dbo_ForecastIn. DataTime, dbo_ForecastInD ata.DataTime;
Here is the code:
-----------------
SQLStmt = "SELECT dbo_ForecastIn. DataTime AS E_Time,
dbo_ForecastInD ata.DataTime AS FD_Time,
dbo_ForecastInD ata.WindFarmPow er AS ForecastPower "
SQLStmt = SQLStmt & "FROM dbo_ForecastIn INNER JOIN
dbo_ForecastInD ata ON dbo_ForecastIn. DataID =
dbo_ForecastInD ata.DataID "
SQLStmt = SQLStmt & "GROUP BY dbo_ForecastIn. DataTime,
dbo_ForecastInD ata.DataTime, dbo_ForecastInD ata.WindFarmPow er "
SQLStmt = SQLStmt & "HAVING dbo_ForecastIn. DataTime = #06/02/2004
16:00:00# "
SQLStmt = SQLStmt & "ORDER BY dbo_ForecastIn. DataTime,
dbo_ForecastInD ata.DataTime;"
response.write( SQLStmt)
Set RS = Connection.Exec ute(SQLStmt)
Hope one of you geniuses can sort me out.
Thanks.
Comment