set connect = server.createobject("adodb.connection")
connect.open "dsn"
sql = "select count(*),'Tabell1' from tabell1 union all " & _
"select count(*),'Tabell2' from tabell2 union all " & _
"select count(*),'Tabell3' from tabell3 "
set rs = connect.execute(sql)
while not rs.eof
response.write rs(1) & " innehåller " & rs(0) & " rader <br>"
rs.movenext
wend
rs.close
connect.close
------------------ essentitia preter non sans multiplicandum
hm, men då funkar väl LarsG:s sätt? annars kan du ju göra som jag sa, fast kalla de rs1, rs2, rs3 osc.. samt: antalPoster1, antalPoster2, antalPoster3 osv..
å sen göra en typ:
Dim svar
svar = rs1("antalPoster1") + rs2("antalPoster2") + rs3("antalPoster3")
Response.Write rs1("antalPoster1") &" + "& rs2("antalPoster2") &" + "& rs3("antalPoster3") &" = "& svar
<%
Dim Total
set connect = server.createobject("adodb.connection")
connect.open "bypath"
tabell1 = "SELECT COUNT(*) AS antalPoster1 FROM apps"
tabell2 = "SELECT COUNT(*) AS antalPoster2 FROM console"
tabell3 = "SELECT COUNT(*) AS antalPoster3 FROM games"
tabell4 = "SELECT COUNT(*) AS antalPoster4 FROM movies"
tabell5 = "SELECT COUNT(*) AS antalPoster5 FROM music"
Set RS1 = connect.Execute(tabell1)
set RS2 = connect.execute(tabell2)
Set RS3 = connect.Execute(tabell3)
set RS4 = connect.execute(tabell4)
Set RS5 = connect.Execute(tabell5)
Total = RS1("antalPoster1") + RS2("antalPoster2") + RS3("antalPoster3") + RS4("antalPoster4") + RS5("antalPoster3")
while not rs.eof
response.write "<font color='red'>" & Total & "</font>"
rs.movenext
wend
rs.close
connect.close
%>
Och då får jag det här felet:
That makes a total of
ADODB.Recordset error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.
<%
Dim Total
set connect = server.createobject("adodb.connection")
connect.open "bypath"
tabell1 = "SELECT COUNT(*) AS antalPoster1 FROM apps"
tabell2 = "SELECT COUNT(*) AS antalPoster2 FROM console"
tabell3 = "SELECT COUNT(*) AS antalPoster3 FROM games"
tabell4 = "SELECT COUNT(*) AS antalPoster4 FROM movies"
tabell5 = "SELECT COUNT(*) AS antalPoster5 FROM music"
Set RS1 = connect.Execute("tabell1")
set RS2 = connect.execute("tabell2")
Set RS3 = connect.Execute("tabell3")
set RS4 = connect.execute("tabell4")
Set RS5 = connect.Execute("tabell5")
Total = Clng(RS1("antalPoster1")) + Clng(RS2("antalPoster2")) + Clng(RS3("antalPoster3")) + Clng(RS4("antalPoster4")) + Clng(RS5("antalPoster5"))
response.write "<font color='red'>" & Total & "</font>"
connect.close
%>
och jag får forfarande samma fel:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
/bypath/total.asp, line 12
Fattar inte vad jag har gjort för fel med Sql uttrycket