Databasekald
Denne kode er i orden den første gang jeg eksekverer \"Search\", men anden gang kommer der fejl. Jeg andvender PWS som testsystem, kan det have noget med det at gøre? Er der eventuelt noget der er bedre at installere som fiktiv server?Her er koden for søgning:
[code]
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">
<HTML>
<HEAD>
<!-- Minus AutoDato -->
<TITLE>Søger</TITLE>
<META NAME=\"Generator\" CONTENT=\"Stone\'s WebWriter 3.5\">
<script>
</script>
</HEAD>
<BODY>
<form name = navform action = \"nyside.asp\" target = \"bund\" method = \"get\">
<H3>Please choose search criteria(s) for Logstor products</H3>
<TABLE BORDER=\"0\" width = 60%>
<TR>
<TD><input type = checkbox name = Market1>Market segment </TD></TD>
<TD><select name = \"market\">
<option value = \"All\" SELECTED >All
<option value = \"District heating - District heating\" >District heating - District heating
<option value = \"District heating - District cooling\" >District heating - District cooling
<option value = \"District heating - Central cooling\" >District heating - Central cooling
<option value = \"District heating - Sanitary\" >District heating - Sanitary
<option value = \"Industrial plants - Pharmaceutical\" >Industrial plants - Pharmaceutical
<option value = \"Industrial plants - Meat & Poultry\" >Industrial plants - Meat & Poultry
<option value = \"Industrial plants - Breweries\" >Industrial plants - Breweries
<option value = \"Industrial plants - Dairies\" >Industrial plants - Dairies
<option value = \"Marine - Newbuilding\" >Marine - Newbuilding
<option value = \"Marine - Retrofitting\" >Marine - Retrofitting
<option value = \"Oil & Gas - Tie back\" >Oil & Gas - Tie back
<option value = \"Oil & Gas - Platforms\" >Oil & Gas - Platforms
<option value = \"Oil & Gas - Refineries\" >Oil & Gas - Refineries
<option value = \"Oil & Gas - Transmission pipelines\" >Oil & Gas - Transmission pipelines
</TD>
</TR>
<TR>
<TD><input type = checkbox name = Name1>System name </TD>
<TD><select name = \"name\">
<option value = \"All\" SELECTED >All
<option value = \"District heating\" >District heating
<option value = \"District cooling\" >District cooling
<option value = \"Portable water\" >Portable water
<option value = \"HT1\" >HT1
<option value = \"HT2\" >HT2
<option value = \"HT3\" >HT3
<option value = \"Process Industries\" >Process Industries
<option value = \"Offshore Oil applications\" >Offshore Oil applications
<option value = \"Onshore Oil applications\" >Onshore Oil applications
<option value = \"Marine applications\" >Marine applications
<option value = \"Special applications\" >Special applications
<option value = \"Low\" >Low
</select></TD>
</TR>
<TR>
<TD><input type = checkbox name = Type1>System type </TD>
<TD><select name = \"type\">
<option value = \"All\" SELECTED >All
<option value = \"Buried system\" >Buried system
<option value = \"Free system\" >Free system
</select></TD>
</TR>
<TR>
<TD><input type = checkbox name = Mat1>Pipe material </TD></TD>
<TD><select name = \"mat\">
<option value = \"All\" SELECTED >All
<option value = \"St. 37.0 BW\" >St. 37.0 BW
<option value = \"St. 35.8 I\" >St. 35.8 I
<option value = \"Galvanized St. 37.0 BW\" >Galvanized St. 37.0 BW
<option value = \"Galvanized St. 35.8 I\" >Galvanized St. 35.8 I
<option value = \"PEX\" >PEX
<option value = \"Cupper R22\" >Cupper R22
<option value = \"AISI 304/316\" >AISI 304/316
</select></TD>
</TR>
<TR>
<TD><input type = checkbox name = Temp1>Flow temperature </TD>
<TD><input type = text name = \"temp\" size = 3 maxlength = 3 value = \"90\"</TD>
</TR>
</TABLE><br>
<input type = submit value = \"Search\">
</form>
</body>
</html>
[/code]
Og her er resultatsiden:
[code]
<% language = javascript %>
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">
<HTML>
<HEAD>
<!-- Minus AutoDato -->
<TITLE>nyside</TITLE>
<META NAME=\"Generator\" CONTENT=\"Stone\'s WebWriter 3.5\">
</HEAD>
<BODY>
<H3>This is the results of the search.</H3>
<%
if request.querystring(\"Name1\") = \"on\" then
set myconn = server.createobject(\"adodb.connection\")
myconn.open \"Driver={microsoft access Driver (*.mdb)};dbq=\"&server.mappath(\"market-products.mdb\")
sql = \"SELECT * FROM markets WHERE name=\'\" + request.querystring(\"name\")+ \"\'\"
set rs = myconn.execute(sql)
if not (rs.bof or rs.eof) then
do while not rs.eof
var = var & \"<TR valign=top><td><font size = 2>\" &_
rs(\"name\")&\"</font></td><td><font size = 2>\" &_
rs(\"type\")&\"</font></td><td><font size = 2>\" &_
rs(\"carrier_material\")&\"</font></td>\"
rs.movenext
loop
end if
rs.close
myconn.close
set myconn = nothing
Response.Write \"<table border = 1 cellspacing=2><caption>Table 1</caption>\"
response.write\"<tr>\"
response.write\"<th bgcolor =#c0c0c0 bordercolor =#000000><font size = 2>System name</font></th>\"
response.write \"<th bgcolor =#c0c0c0 bordercolor =#000000><font size = 2>Type</font></th>\"
response.write \"<th bgcolor =#c0c0c0 bordercolor =#000000><font size = 2>Material</font></th>\"
response.write \"</tr>\"
end if
%>
<%=var %>
</table>
</BODY>
</HTML>
[/code]