473,409 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

ASP query runtime error 800a0401

I have the following SQL query that keeps giving me a runtime error 800a0401when running through an asp page. The query is below:

SELECT (Sum(Abs(DSum("Cath_type","tbl1a_IC")))/10*100) AS CT_Total, (Sum(Abs(DSum("Insertion_site","tbl1a_IC")))/10*100) AS IS_Total, (Sum(Abs(DSum("Skin_prep","tbl1a_IC")))/10*100) AS SP_Total, (Sum(Abs(DSum("PP_eqip","tbl1a_IC")))/10*100) AS PPE_Total, Sum(Abs(DSum("Hand_hy","tbl1a_IC")))/10*100 AS HH_Total, (Sum(Abs(DSum("Aseptic_tec","tbl1a_IC")))/10*100) AS AAT_Total, (Sum(Abs(DSum("Dressing","tbl1a_IC")))/10*100) AS D_Total, (Sum(Abs(DSum("SDos","tbl1a_IC")))/10*100) AS SDOS_Total, (Sum(Abs(DSum("Doc","tbl1a_IC")))/10*100) AS DOC_Total
FROM tbl1a_IC
GROUP BY tbl1a_IC.OBID, IIf([Dressing]=Yes,"1","0"), IIf([SDoS]=Yes,"1","0"), IIf([Doc]=Yes,"1","0"), IIf([PP_eqip]=Yes,"1","0"), IIf([Hand_hy]=Yes,"1","0"), IIf([Aseptic_tec]=Yes,"1","0"), IIf([Cath_type]=Yes,"1","0"), IIf([Insertion_site]=Yes,"1","0"), IIf([Skin_prep]=Yes,"1","0")
HAVING (((tbl1a_IC.OBID)=1));

This is the page code:

<html>
<head>
<title>test</title>
</head>
<body bgcolor="black" text="white">

<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsInfection 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("infection.mdb")

'Create an ADO recordset object
Set rsInfection = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT (Sum(Abs(DSum("Cath_type","tbl1a_IC")))/10*100) AS CT_Total, (Sum(Abs(DSum("Insertion_site","tbl1a_IC")))/10*100) AS IS_Total, (Sum(Abs(DSum("Skin_prep","tbl1a_IC")))/10*100) AS SP_Total, (Sum(Abs(DSum("PP_eqip","tbl1a_IC")))/10*100) AS PPE_Total, Sum(Abs(DSum("Hand_hy","tbl1a_IC")))/10*100 AS HH_Total, (Sum(Abs(DSum("Aseptic_tec","tbl1a_IC")))/10*100) AS AAT_Total, (Sum(Abs(DSum("Dressing","tbl1a_IC")))/10*100) AS D_Total, (Sum(Abs(DSum("SDos","tbl1a_IC")))/10*100) AS SDOS_Total, (Sum(Abs(DSum("Doc","tbl1a_IC")))/10*100) AS DOC_Total
FROM tbl1a_IC
GROUP BY tbl1a_IC.OBID, IIf([Dressing]=Yes,"1","0"), IIf([SDoS]=Yes,"1","0"), IIf([Doc]=Yes,"1","0"), IIf([PP_eqip]=Yes,"1","0"), IIf([Hand_hy]=Yes,"1","0"), IIf([Aseptic_tec]=Yes,"1","0"), IIf([Cath_type]=Yes,"1","0"), IIf([Insertion_site]=Yes,"1","0"), IIf([Skin_prep]=Yes,"1","0")
HAVING (((tbl1a_IC.OBID)=1)));"

response.write vbNewLine & strSQL & "<br>" & vbNewLine

'Open the recordset with the SQL query
rsInfection.Open strSQL, adoCon

'Loop through the recordset
Do While not rsInfection.EOF


'Write the HTML to display the current record in the recordset
Response.Write ("<br>")
Response.Write (rsInfection("CT_Total"))
Response.Write ("<br>")
Response.Write (rsInfection("IS_Total"))
Response.Write ("<br>")
Response.Write (rsInfection("SP_Total"))
Response.Write ("<br>")
Response.Write (rsInfection("PPE_Total"))
Response.Write ("<br>")
Response.Write (rsInfection("HH_Total"))
Response.Write ("<br>")
Response.Write (rsInfection("AT_Total"))
Response.Write ("<br>")
Response.Write (rsInfection("D_Total"))
Response.Write ("<br>")
Response.Write (rsInfection("SDOS_Total"))
Response.Write ("<br>")
Response.Write (rsInfection("DOC_Total"))
Response.Write ("<br>")

'Move to the next record in the recordset
rsInfection.MoveNext
Loop

'Reset server objects
rsInfection.Close
Set rsInfection = Nothing
Set adoCon = Nothing
%>

</body>
</html>


Any help you could give me would be much appreciated. Im pretty new to this.
Jan 24 '08 #1
1 1768
DrBunchman
979 Expert 512MB
joe,

I think the problem is that you are using double quotes within your strSQL variable - i've taken the first line of strSQL as an example:

strSQL = "SELECT (Sum(Abs(DSum("Cath_type","tbl1a_IC")))/10*100) AS CT_Total, (Sum

An asp string begins and ends with double quotes so the server is seeing strSQL as

strSQL = "SELECT (Sum(Abs(DSum("

because that is the text between the first two sets of double quotes. If you want to use double quotes INSIDE a string then you must use two double quotes next to each other e.g. "" in a string means ". So your first line would look like:

strSQL = "SELECT (Sum(Abs(DSum(""Cath_type"",""tbl1a_IC"")))/10*100) AS CT_Total, (Sum

Either that or some functions will let you use a single quote ' instead of a double quote inside a string.

Hope that helps

Dr B
Jan 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Phil Powell | last post by:
Here is the function ArraySearch: '-------------------------------------------------------------------------------------- 'ArraySearch will return an integer value indicating the first...
2
by: Matthew Louden | last post by:
I have no idea what's wrong with the following ASP statement: Response.Write "<select name=\"id\">" MS VBScript Compilation error 800a0401 expected end of statement However, if I do the...
9
by: Luc Dal | last post by:
Hello, I've serious problem using ASP under WindowsXP sp2. I get the following reply (sorry it's in french) Erreur de compilation Microsoft VBScript error '800a0401' Fin d'instruction...
13
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a...
11
by: DraguVaso | last post by:
Hi, I want to make a small application in VB.NET that relinks all the query's and tables in an Access database that are linked via ODBC to an SQL Server. It must be able to relink all the tables...
21
by: CSN | last post by:
I have a pretty simple select query that joins a table (p) with 125K rows with another table (pc) with almost one million rows: select p.* from product_categories pc inner join products p on...
11
by: remya1000 | last post by:
While running the program, i'm getting this error Microsoft VBScript compilation error '800a0401' Expected end of statement /admin/currentmonth.asp, line 26 strSQL = "SELECT...
3
by: DracoZA | last post by:
Can anyone tell me where the problem is here ? - Thanks Error: Microsoft VBScript compilation error '800a0401' Expected end of statement /test/ADO/demo_add.asp, line 15
7
by: siocodes | last post by:
I know I am so close on this, but I cannot see what the syntax fix is. I am sending two e-mails via one asp page; one to the gift giver and one to the recipient...I originally had the message text in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.