---
title: "End If förväntas"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/13421-end-if-förväntas"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "ampy"
published: "2001-12-29T15:19:00.000Z"
updated: "2001-12-29T16:52:00.000Z"
replies: 14
views: 439
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/13421-end-if-förväntas"
---

# End If förväntas

## #1 — ampy, 2001-12-29T15:19Z

End If förväntas i följande kod men jag har letat men hittar inte vart jag ska lägga in den. Hoppas ni kan hjälpa mig :)

```

<%
	
	
	Set Conn	= Server.CreateObject("ADODB.Connection")
	Set DBLink	= Server.CreateObject("ADODB.Recordset")

		Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../db/linkcounter=spel.mdb") & ";pwd=;"

		SQL = "SELECT * From LinkCounter ORDER BY id"
		DBLink.Open SQL, Conn, 1, 2

			If Not RecSet.EOF Then
		
Do Until RecSet.EOF
	
x = 0

if x = 2 then
t = "#FFE08B"

else
t = "#FFCC51"
end if

			
				%>

		<TABLE style='BORDER-BOTTOM: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-LEFT: #000000 1px solid' 
		borderColor=#000000 borderColor=#000000 cellSpacing=0 width=475 
		borderColorLight=#000000 border=0>
 
		<TR>
    
 		<TD 
  		width=475 bgcolor='&t&' height=17><FONT face=Verdana 
  		color=#000000 size=1><FONT face=Verdana color=#000000 size=1>

		<%
Response.Write "<br> <a href=""" & adress & """action=in&id="" & DBLink('ID') & """>" & DBLink('Namn') & "'</a>'" &vbCrLf
		%>

		</FONT></TD></TR>

  

		</table><%
				
				
				
				

				DBLink.MoveNext

			

		DBLink.Close
		Conn.Close

	Set DBLink = Nothing
	Set Conn = Nothing
	
	End If
	
	
%>
```

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

## #2 — jorgen, 2001-12-29T15:30Z

borde vara:

```
<%

Set Conn = Server.CreateObject("ADODB.Connection")
Set DBLink = Server.CreateObject("ADODB.Recordset")

Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../db/linkcounter=spel.mdb") & ";pwd=;"

SQL = "SELECT * From LinkCounter ORDER BY id"
DBLink.Open SQL, Conn, 1, 2

If [b]DBLink.EOF Then

response.write "Inget fanns"

else [/b]

Do Until [b]DBLink.EOF[/b]

x = 0

if x = 2 then
t = "#FFE08B"

else
t = "#FFCC51"
end if

%>

<TABLE style='BORDER-BOTTOM: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-LEFT: #000000 1px solid' 
borderColor=#000000 borderColor=#000000 cellSpacing=0 width=475 
borderColorLight=#000000 border=0>

<TR>

<TD 
width=475 bgcolor='&t&' height=17><FONT face=Verdana 
color=#000000 size=1><FONT face=Verdana color=#000000 size=1>

<%
Response.Write "<br> <a href=""" & adress & """action=in&id="" & DBLink('ID') & """>" & DBLink('Namn') & "'</a>'" &vbCrLf
%>

</FONT></TD></TR>

</table><%

DBLink.MoveNext

[b]loop[/b]

End If

DBLink.Close
Conn.Close

Set DBLink = Nothing
Set Conn = Nothing

%>
```

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

## #3 — jimpa, 2001-12-29T15:33Z

Hej,

Prova så här:

```
DBLink.MoveNext

Loop

End If

DBLink.Close
Conn.Close

Set DBLink = Nothing
Set Conn = Nothing
```

Mvh
Jimpa

\[Redigerat av jimpa den 29 dec 2001\]

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

## #4 — ampy, 2001-12-29T15:39Z

Jag kopierade hela din kod och den funkade bra men nu får jag detta felmeddelande:

```
Körningsfel i Microsoft VBScript fel '800a01f4' 

Odefinierad variabel: 'x' 

/spel/onlinespel.asp, line 182
```

```
[b]x = 0[/b]

if x = 2 then
color = "#FFE08B"

else
color = "#FFCC51"
end if
```

Rad 182 är skriven med fet stil.

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

## #5 — jorgen, 2001-12-29T15:47Z

Hej, du kan inte skriva ut asp utanför asp-avgränsare:

```
<TD 
width=475 bgcolor='&t&' height=17><FONT face=Verdana 
color=#000000 size=1><FONT face=Verdana color=#000000 size=1>
```

```
<%

Set Conn = Server.CreateObject("ADODB.Connection")
Set DBLink = Server.CreateObject("ADODB.Recordset")

Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../db/linkcounter=spel.mdb") & ";pwd=;"

SQL = "SELECT * From LinkCounter ORDER BY id"
DBLink.Open SQL, Conn, 1, 2

If DBLink.EOF Then

response.write "Inget fanns"

else 

Do Until DBLink.EOF

Dim color
Dim counter
counter = counter + 1
If counter Mod 2 = 0 then
color = "#FFE08B"
Else
color = "#FFCC51"
End If

%>

<TABLE style='BORDER-BOTTOM: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-LEFT: #000000 1px solid' 
borderColor=#000000 borderColor=#000000 cellSpacing=0 width=475 
borderColorLight=#000000 border=0>

<%

response.write "<TR bgcolor="""&color&""">"

%>

<TD 
width=475 height=17><FONT face=Verdana 
color=#000000 size=1><FONT face=Verdana color=#000000 size=1>

<%
Response.Write "<br> <a href=""" & adress & """action=in&id="" & DBLink('ID') & """>" & DBLink('Namn') & "'</a>'" &vbCrLf
%>

</FONT></TD></TR>

</table><%

DBLink.MoveNext

loop

End If

DBLink.Close
Conn.Close

Set DBLink = Nothing
Set Conn = Nothing

%>
```

RED: antog att du ville byta färg på varannan rad?

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

## #6 — ampy, 2001-12-29T15:57Z

Nu funkar det men det står **True** i alla kolumner i tabellen.

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

## #7 — jorgen, 2001-12-29T15:59Z

:q

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

## #8 — ampy, 2001-12-29T16:04Z

Alltså när jag skriver ut denna rad:

```
Response.Write "<br> <a href=""" & adress & """action=in&id="" & DBLink('ID') & """>" & DBLink('Namn') & "'</a>'" &vbCrLf
```

Så skriver den ut **True**

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

## #9 — jorgen, 2001-12-29T16:07Z

```
Response.Write "<br><a href="""&adress &""" action=in&id="" "& DBLink("ID") & """>" & DBLink("Namn") & "</a>"
```

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

## #10 — PatrikB, 2001-12-29T16:10Z

Då är innehållet i: DBLink('Namn')  = True

dvs, du måste lagt in true i fältet i databasen ....

cya,
PatrikB

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

## #11 — ampy, 2001-12-29T16:12Z

Nu skriver den ut rätt men istället blev höjden på kolumnen dubbelt så hög. Det ser inte så snyggt ut, varför blir det så?

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

## #12 — jorgen, 2001-12-29T16:18Z

Kan bero på att du lagt in en radbrytning ( \<br\> ) innan länken.

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

## #13 — ampy, 2001-12-29T16:20Z

Oj, tack så mycket jorgen, det såg inte jag ;)

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

## #14 — ampy, 2001-12-29T16:49Z

Jag kom på en sak som jag inte märkte förut: På denna rad:

```
Response.Write "&nbsp;&nbsp;<a href="""&adress &""" action=in&id="" "&DBLink("ID") & """>" & DBLink("Namn") & "</a>"
```

Så blir länken bara **linkcounter.asp**

Varför???

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

## #15 — icaaq, 2001-12-29T16:52Z

```
Response.Write "  <a href="""&adress &"?action=in&id="&DBLink("ID") & """>" & DBLink("Namn") & "</a>"
```

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/13421-end-if-förväntas
