Finns det någon möjlighet att göra följande kod enklare?
(den fungerar hur bra som helst förövrigt men det blir bara så mycket)
Tacksam för all hjälp.
// Jonas
set connection=server.createobject("adodb.connection")
connection.open "dsn=rd1"
stm1= "select Count(*) AS swe1 from cbslotts where landslott='Sverige' and cbtid= #" &date &"# and cbslott='08:00-09:00' and 1 = 1 "
set rs = connection.execute(stm1)
if isnull(rs("swe1")) then
swe1 = 0
else
swe1 = round(rs("swe1"))
end if
stm2= "select Count(*) AS swe2 from cbslotts where landslott='Sverige' and cbtid= #" &date &"# and cbslott='09:00-10:00' and 1 = 1 "
set rs = connection.execute(stm2)
if isnull(rs("swe2")) then
swe2 = 0
else
swe2 = round(rs("swe2"))
end if
stm3= "select Count(*) AS swe3 from cbslotts where landslott='Sverige' and cbtid= #" &date &"# and cbslott='10:00-11:00' and 1 = 1 "
set rs = connection.execute(stm3)
if isnull(rs("swe3")) then
swe3 = 0
else
swe3 = round(rs("swe3"))
end if
stm4= "select Count(*) AS swe4 from cbslotts where landslott='Sverige' and cbtid= #" &date &"# and cbslott='15:00-16:00' and 1 = 1 "
set rs = connection.execute(stm4)
if isnull(rs("swe4")) then
swe4 = 0
else
swe4 = round(rs("swe4"))
end if
stm5= "select Count(*) AS swe5 from cbslotts where landslott='Sverige' and cbtid= #" &date &"# and cbslott='16:00-17:00' and 1 = 1 "
set rs = connection.execute(stm5)
if isnull(rs("swe5")) then
swe5 = 0
else
swe5 = round(rs("swe5"))
end if
rs.close
Connection.close
Set Connection = Nothing
Tebax till "grundinlägget":
Jag ser inte att du skriver ut någonting någon gång i koden.
Hur ser den delen ut?
V.V. använd [kod]-taggar när du skriver ut kod.
set connection=server.createobject("adodb.connection")
connection.open "dsn=rd1"
stm1= "SELECT landslott,cbtid,cbslott,Count(*) AS swe from cbslotts where landslott='Sverige' and cbtid= #" &date &"# and 1 = 1 GROUP BY cbslott"
set rs = connection.execute(stm1)
Do until rs.eof
response.write("Land: "&rs("landslott") & " något:" & rs("cbslott") & " Antal: "& rs("swe")&" något:"& rs("cbtid")&"<br>")
rs.movenext
loop
jag får då följande fel:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Du försökte köra en fråga med en mängdfunktion som inte innehöll det angivna uttrycket 'landslott'.
/ccr/rd/test.asp, line 17
line 16=stm1= "SELECT landslott,cbtid,cbslott,Count(*) AS swe from cbslotts where landslott='Sverige' and cbtid= #" &date &"# and 1 = 1 GROUP BY cbslott"
line 17 =set rs = connection.execute(stm1)
stm1= "SELECT landslott,cbtid,cbslott,Count(*) AS swe from cbslotts " & _
" where landslott='Sverige' " & _
" and cbtid= #" &date &"# " &
" GROUP BY landslott,cbtid,cbslott"
Nu funkar det klockrent (det saknades ett "underscore" dock, men det löstes utan större problem)
Och jag tog bort raden " " where landslott='Sverige' " & _
"
För alla "länderna skulle räknas upp inte bara Sverige
Tack igen
// Jonas
260 ms totalt · 4 externa anrop · v20260731065814-full.51f67c91