---
title: "får inte else att fungera"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/103930-får-inte-else-att-fungera"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "timedia"
published: "2004-05-19T16:54:40.000Z"
updated: "2004-05-19T17:00:27.000Z"
replies: 2
views: 220
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/103930-får-inte-else-att-fungera"
---

# får inte else att fungera

## #1 — timedia, 2004-05-19T16:54Z

Hur gör jag för att skriva 'inga träffar' när jag inte har nåt som motsvara sökvärdet i db?

```
<% 
midd = Request.querystring("id")
Land = Request.Form("land")

Set RS = Server.CreateObject("ADODB.Recordset")
Visa = "SELECT * FROM Lan ORDER BY Id"
RS.Open Visa, Connect  %>
<b>Välj län:</b><br>
<form method="post">
<input type="hidden" name="midd" value="<% =midd %>">
<select name="land" size="5">
<%
Do While Not rs.EOF
%>
<option value="<% =rs("lan") %>"><% =rs("lan")%></option>
<%
rs.MoveNext
Loop
RS.Close: Set rs = nothing
%></select>
<td width="320" height="15" align="right" valign="top" class="bildtext"></td></tr>
		<tr><td width="320" height="*" align="left" valign="top" class="brodtext">
<input type="submit" value="Search" name="Action"></form>
<% If Request.form("midd") <> "" AND Request.form("land") <> "" Then 
			Set RS = Server.CreateObject("ADODB.Recordset")
Visa = "SELECT * from Lankar WHERE Lan='"&Request.form("land")&"' AND Kategori="&Request.form("midd")&" ORDER BY kommun "

pk = ""
RS.Open Visa, Connect
Do While Not rs.EOF
      if  pk <> rs("kommun") then
          pk = rs("kommun")
          response.write "<B>" & pk & "</B><br>"
	  end if
      response.write RS("Lanktxt")&"<br>"
      rs.Movenext
Loop
RS.Close: Set rs = nothing

	end if
%>
```

Permalänk: https://www.webforum.nu/p/103930

## #2 — cyprys, 2004-05-19T16:58Z

```
RS.Open Visa, Connect
if rs.eof then
  response.write "Inga träffar"
else
  Do While Not rs.EOF
      if  pk <> rs("kommun") then
          pk = rs("kommun")
          response.write "<B>" & pk & "</B><br>"
	  end if
      response.write RS("Lanktxt")&"<br>"
      rs.Movenext
  Loop
  RS.Close: Set rs = nothing
end if
```

Permalänk: https://www.webforum.nu/p/1351210

## #3 — timedia, 2004-05-19T17:00Z

Wow... hur enkelt som hälst :)

Permalänk: https://www.webforum.nu/p/1351212

---

Tråden på webben: https://www.webforum.nu/amne/asp/103930-får-inte-else-att-fungera
