jonas76Medlem sedan mars 200278 inlägg
Hej
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
Jesper TMedlem sedan nov. 20017 058 inlägg
För kännedom:Det är ett grymt säkerhetshål på din inloggningssida.
Det skulle sitta bra med lite replace ;)
jonas76Medlem sedan mars 200278 inlägg
Ajdå det låter ju inte bra vill du förklara lite bättre?
Tack för din info :)
Jesper TMedlem sedan nov. 20017 058 inlägg
Vad är det den koden skall göra?
jonas76Medlem sedan mars 200278 inlägg
Menar du ovanstående kod eller menar du den till inloggningen?
Jesper TMedlem sedan nov. 20017 058 inlägg
Ovanstående kod menar jag.
Detta är till inloggningen:
function fixa(fix)
fix = Replace(fix,"'", "''")
fix = Replace(fix,"|","")
fixa = fix
end function
username = fixa(Request.Form("username"))
password = fixa(Request.Form("password"))
jonas76Medlem sedan mars 200278 inlägg
TAck för "fixen" :)
Ovanstående kod.
Jo jag skall ha en summering för olika kriterier som jag sedan redovisar på sidan med tex:
<tr bgcolor="silver">
<td width="100">Land: <font color="blue">Sverige</font></td>
<td width="150">Tid: <font color="blue">08:00-09:00</font></td>
<td width="100">Antal: <font color="blue"><%=swe1%></font></td>
</tr>
osv.........
Jesper TMedlem sedan nov. 20017 058 inlägg
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.
Jesper TMedlem sedan nov. 20017 058 inlägg
Det är nog smartare om du loopar ut hela recsetet på någe vis.
jonas76Medlem sedan mars 200278 inlägg
<tr bgcolor="silver">
<td width="100">Land: <font color="blue">Sverige</font></td>
<td width="150">Tid: <font color="blue">08:00-09:00</font></td>
<td width="100">Antal: <font color="blue"> <%=swe1%> </font></td>
</tr><%=swe1%>
Nu syns det bättre :)
Jesper TMedlem sedan nov. 20017 058 inlägg
Något liknande kanske:
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
jonas76Medlem sedan mars 200278 inlägg
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)
LarsGMedlem sedan dec. 200012 465 inlägg
stm1= "SELECT landslott,cbtid,cbslott,Count(*) AS swe from cbslotts " & _
" where landslott='Sverige' " & _
" and cbtid= #" &date &"# " &
" GROUP BY landslott,cbtid,cbslott"
jonas76Medlem sedan mars 200278 inlägg
Tusen Tack :)
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