---
title: "Felaktigt matrisindex: 'i'"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/14264-felaktigt-matrisindex-i"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "andreas_lindh"
published: "2002-02-07T15:34:00.000Z"
updated: "2002-02-07T16:09:00.000Z"
replies: 3
views: 374
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/14264-felaktigt-matrisindex-i"
---

# Felaktigt matrisindex: 'i'

## #1 — andreas_lindh, 2002-02-07T15:34Z

Kan någon se vad som är fel?

```
<% match_id=split(request.form("match_id"),",")
lag_id=split(Request.form("lag_id"),",")
spelar_id=split(Request.Form("id"),",")
spelar=split(Request.Form("spelar"),",")

for i = 1 to request.form("spelar").count
sql = "Insert into c_protokoll (match_id, lag_id,spelar_id,spelar)"
sql = sql & " Values ('" & trim(match_id(i)) & "', '" & trim(lag_id(i)) & "', '" & trim(spelar_id(i)) & "', '" & trim(spelar(i)) & "')"
next
oConn.Execute(sql)
oconn.close
%>
```

Får detta felmeddelandet:
Feltyp:
Körningsfel i Microsoft VBScript (0x800A0009)
Felaktigt matrisindex: 'i'
/tikcup/edit_schema.asp, line 437

\[Redigerat av andreas_lindh den 07 feb 2002\]

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

## #2 — LarsG, 2002-02-07T15:45Z

arrayindex startar på 0

```
sql = "Insert into c_protokoll (match_id, lag_id,spelar_id,spelar)"
sql = sql & " Values ('" & trim(match_id(i-1)) & "', '" & trim(lag_id(i-1)) & "', '" & trim(spelar_id(i-1)) & "', '" & trim(spelar(i-1)) & "')"
```

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

## #3 — andreas_lindh, 2002-02-07T15:55Z

Jag ändrade till

```
<% 
match_id=split(request.form("match_id"),",")
lag_id=split(Request.form("lag_id"),",")
spelar_id=split(Request.Form("id"),",")
spelar=split(Request.Form("spelar"),",")

for i = 0 to request.form("spelar").count
sql = "Insert into c_protokoll (match_id, lag_id,spelar_id,spelar)"
sql = sql & " Values (" & trim(match_id(i)) & ", " & trim(lag_id(i)) & ", " & trim(spelar_id(i)) & ", " & trim(spelar(i)) & ")"
next
oConn.Execute(sql)
%>
```

Det borde väl vara samma men det fungerar inte.
Den första fungerar inte heller som den ska. Den lägger bar till en post fast det ska vara flera.

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

## #4 — LarsG, 2002-02-07T16:09Z

Nej, det är inte samma sak. 

Anledningen till att du bara får in en post är att du bara gör execute en gång.

```
oConn.Execute sql
```

Flytta in den i for-loopen.

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/14264-felaktigt-matrisindex-i
