---
title: "Function FieldExist"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/38219-function-fieldexist"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "Vide"
published: "2001-08-21T09:19:00.000Z"
updated: "2001-08-21T09:19:00.000Z"
replies: 0
views: 881
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/38219-function-fieldexist"
---

# Function FieldExist

## #1 — Vide, 2001-08-21T09:19Z

En liten funktion jag gjort för att kolla om ett fält finns i en tabell finns eller inte. Skicka med din connectionstring, vilken tabell och vilket fält, så får du tillbaks true om fältet finns eller false om det inte finns. :)

```
'** Checks if the strField exists in strTable.
Function FieldExist( conStr , strTable , strField )

  Set rs = Server.CreateObject("ADODB.Recordset")
  strSQL = "SELECT Top 1 * FROM " & strTable
  rs.Open strSQL, conStr

  For i = 0 to rs.Fields.Count - 1
    If strField = rs.Fields(i).Name Then
      bolCheck = true
      Exit For
    End If
  Next
  
  rs.close
  Set rs = nothing
  
  If bolCheck Then
    FieldExist = true
  Else
    FieldExist = false
  End If

End Function
```

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/38219-function-fieldexist
