webForumDet fria alternativet

If, Querystring, Include Prestanda

6 svar · 275 visningar · startad av erka

erkaMedlem sedan dec. 19994 597 inlägg
#1

Jag har en sida som först ser ut så här

% If Request.Querystring("action") = "0" Then %>
<!--#include file="code/dist0.code"-->
<% ElseIf Request.Querystring("action") = "1" Then %>
<!--#include file="code/dist1.code"-->
<% ElseIf Request.Querystring("action") = "2" Then %>
<!--#include file="code/dist2.code"-->
<% End If %>

sen ser .code filerna ut så tex så här


<%

Response.Write"<table width='600' border='0'><tr><td width='25'></td><td width='585' class='txtmain'><table cellpadding='0' cellspacing='0' border='0' width='500'><tr class='txtmain'><td>"

Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=c:\inetpub\wwwroot\db\customer00.mdb" 

'SÄTTER VÄRDET FRÅN FORMULÄRKNAPPARNA TILL EN COOKIE SAMMLING
Response.Cookies("koll")("a1") = request.form("a1")
Response.Cookies("koll")("a2") = request.form("a2")
Response.Cookies("koll")("a3") = request.form("a3")
Response.Cookies("koll")("a4") = request.form("a4")
Response.Cookies("checkflagg") = "False"

if request.cookies("koll")("a1") > "" Then
IntAutomation = "1"
Response.Cookies("checkflagg") = "True"
a1 = true
End If

If request.cookies("koll")("a2") > "" Then
IntConveying = "2"
Response.Cookies("checkflagg") = "True"
a2 = true
End If

If request.cookies("koll")("a3") > "" Then
IntGap = "3"
Response.Cookies("checkflagg") = "True"
a3 = true
End If

If request.cookies("koll")("a4") > "" Then
IntLabVac = "4"
Response.Cookies("checkflagg") = "True"
a4 = true
End If

'KOLLA OM MAN VALDE NÅGOT ÖVER HUVUD TAGET
If Request.Cookies("checkflagg") = "False" Then
Response.Write"Du valde inte någon produkt grupp"
Connect.Close

End If

StrSQL = "Select CountryRep.CountryRepENG, d1.CustomerType, D1.Automation, D1.Transport, d1.Labvacs, d1.GAP FROM D1 INNER JOIN CountryRep On D1.CustomerID = CountryRep.CustomerID GROUP BY CountryRep.CountryRepENG, d1.Companyname, d1.Customertype, d1.automation, d1.transport, d1.Labvacs, d1.gap HAVING "
StrSQLAutomation = "d1.Automation='"
StrSQLConveying = "d1.Transport='"
StrSQLGap = "d1.Gap='"
StrSQLLabVacs ="d1.Labvacs='"
StrSQLClose = "' Order By CountryREP.CountryRepENG"
StrSQLAnd = "' OR "

If a1 = true Then
StrSQL = StrSQL & StrSQLAutomation & IntAutomation
If a2= true Or a3 = true Or a4 = true Then
StrSQL = StrSQL & StrSQLAnd
End If
End If

If a2 = true Then
StrSQL = StrSQL & StrSQLConveying & IntConveying
If a3 = true Or a4 = true Then
StrSQL = StrSQL & StrSQLAnd
End If
End If

If a3 = true Then
StrSQL = StrSQL & StrSQLGap & IntGap
If a4 = true Then
StrSQL = StrSQL & StrSQLAnd
End If
End If

If a4 = true Then
StrSQL = StrSQL & StrSQLLabVacs & IntLabVac
End If
StrSQL = StrSQL & StrSQLClose
Prevcountry = "nothing"
Set RS = Connect.Execute(StrSQL)

Response.Write"<span class='P_header1'>Distributors</span><br>"

Response.Write"Selected Product group(s):<br>"
If Request.Cookies("koll" & a1).Haskeys = FALSE Then 
Response.Write"-Pumps, Suction Cups, Logics<br>"
End If

If Request.Cookies("koll" & a2).Haskeys = FALSE Then 
Response.Write"-Vacuum Conveying<br>"
End If

If Request.Cookies("koll" & a3).Haskeys = FALSE Then 
Response.Write"-Graphic Air Pumps<br>"
End If

If Request.Cookies("koll" & a4).Haskeys = FALSE Then 
Response.Write"-Lab Vacs<br>"
End If

Response.Write"<br><br>The product group(s) you have selected have distributors in the following countries:<br>"

response.write"<table width='500' border='0' cellspacing='0' cellpadding='0'><tr><td width='128' valign='middle'><FORM method='post' action='distributors.asp?action=2'><SELECT Name='StrCountry' class='txtbox'>"

While NOT RS.EOF
If prevCountry <> rs("CountryRepENG") Then
Response.Write"<option>"
Response.Write rs("CountryRepENG")
Response.Write"</option>"'
PrevCountry = RS("CountryRepENG")
RS.MoveNext
Else
Rs.MoveNext
End If
Wend
RS.Close
Connect.Close

Response.Write"</select></td><td width='372' valign='middle'><br><input src='images/cmd_go.gif' name='skicka' border='0' type='image'></form></td></tr></table></tr></table></td></tr></table>"
%>

Jag läste någon stanns att han går igenom alla include filer redan när man gör if / querystring sattsen. Om det är så borde ju ett sådant här sett att gå tillväga ta mer kräm än om man delat upp den på 3 filer ? har jag rätt eller helt fel ?

tacksam

------------------
1 Man, 1 Million dead, The odds are just about even - Ash

[Redigerat av erka den 15 feb 2001]

VideMedlem sedan dec. 19996 094 inlägg
#2

Du har rätt... plus en detalj: Includefilernas innehåll hämtas innan du har hunnit till tolkningen av koden, dvs din if-sats...

Med ASP 3.0 kan du istället för include köra Server.execute, vilket du på dynamiskt sätt kan strukturera upp som ett mer servervänligt upplägg... oj, ordbajs... ;)

[R]Glömde viktig info![/R]

------------------
Nu har du sjungit på sista refrängen
Jourhavande Vide

[Redigerat av Vide den 15 feb 2001]

erkaMedlem sedan dec. 19994 597 inlägg
#3

Så jag skulle kunna skriva ut mina .code filer som bara inehåller asp, massa response writar (tabeller) å annan kod då med server.execute...

Prestanda mässigt ? tar det mycket kraft ?

------------------
1 Man, 1 Million dead, The odds are just about even - Ash

VideMedlem sedan dec. 19996 094 inlägg
#4

Nja, det skulle vara mindra krävande än din nuvarande kod...

Om skillnaden mellan dina filer tillåter det så skulle jag nog bygga en funktion eller sub av det hela, och skicka med det lilla som skall ändras...

------------------
Nu har du sjungit på sista refrängen
Jourhavande Vide

erkaMedlem sedan dec. 19994 597 inlägg
#5

Det är rätt stor skillnad på dem så jag vet inte...Är server.execute grymt prestanda slukande eller ?

------------------
1 Man, 1 Million dead, The odds are just about even - Ash

VideMedlem sedan dec. 19996 094 inlägg
#6

Nej! :)

------------------
Nu har du sjungit på sista refrängen
Jourhavande Vide

erkaMedlem sedan dec. 19994 597 inlägg
#7

tack så mycket du är en riktig **bäjby**

------------------
1 Man, 1 Million dead, The odds are just about even - Ash

Genererad på 377 ms · cache AV · v20260730165559-full.f96bc7eb