---
title: "Fel i INSERT INTO-uttryck..."
type: "forum-thread"
url: "https://www.webforum.nu/amne/databaser-sql/86945-fel-i-insert-into-uttryck"
topic: "Databaser & SQL"
topic_url: "https://www.webforum.nu/amne/databaser-sql"
author: "Fredde Mannen"
published: "2003-09-25T14:38:25.000Z"
updated: "2003-09-25T20:48:37.000Z"
replies: 8
views: 279
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/databaser-sql/86945-fel-i-insert-into-uttryck"
---

# Fel i INSERT INTO-uttryck...

## #1 — Fredde Mannen, 2003-09-25T14:38Z

Jag har denna sql-sträng som jag kör mot en Access-databas, men den ger fel... men mot MySQL funkar den... varför??

```
SQL = "INSERT INTO articles(Subject, Article, Dat, Section) VALUES("
SQL = SQL & "'" & txtSubject & "'"
SQL = SQL & ",'" & txtContent & "'"
SQL = SQL & ",'" & txtDatum & "'"
SQL = SQL & ",'" & txtSection & "'"
SQL = SQL & ")"
```

 :q

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

## #2 — Josef, 2003-09-25T14:39Z

Kan vara att Access vill ha # runt datum.

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

## #3 — SteveP, 2003-09-25T14:40Z

```
SQL = "INSERT INTO articles(Subject, Article, Dat, Section) VALUES("
SQL = SQL & "'" & txtSubject & "'"
SQL = SQL & ",'" & txtContent & "'"
SQL = SQL & ",'#" & txtDatum & "#'"
SQL = SQL & ",'" & txtSection & "'"
SQL = SQL & ")"
```

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

## #4 — Fredde Mannen, 2003-09-25T14:45Z

> **Josef skrev:**
>
> Kan vara att Access vill ha # runt datum.

Det skall inte behövas eftersom jag inte använder datum/tid utan text, nåja, min kod ser ut så här: 

```
if(Request.QueryString("do") = "news") Then

txtSubject = Replace(Request.Form("txtRubrik"),"'","''")
txtSection = Replace(Request.Form("txtSektion"),"'","''")
txtContent = Replace(Request.Form("txtContent"),"'","''")

if NOT len(month(now)) = 2 Then
manad = "0" & month(now)
else
manad = month(now)
end if

if NOT len(day(now)) = 2 Then
dag = "0" & day(now)
else
dag = day(now)
end if

txtDatum = "" & year(now) & "-" & manad & "-" & dag & ""

SQL = "INSERT INTO articles(Subject, Article, Dat, Section) VALUES("
SQL = SQL & "'" & txtSubject & "'"
SQL = SQL & ",'" & txtContent & "'"
SQL = SQL & ",'" & txtDatum & "'"
SQL = SQL & ",'" & txtSection & "'"
SQL = SQL & ")"

MyConn.ExeCute(SQL)
Response.Redirect("Default.asp?usefile=nyheter")
End if
```

Då skall jag ju inte behöva  #... :q

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

## #5 — Josef, 2003-09-25T14:47Z

Har du provat att köra *Response.Write* på sql:en?

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

## #6 — Mika3l, 2003-09-25T15:33Z

Vad får du för felmeddelande?

Subject, Article och Section är inte reserverade ord då?
Testa att skriva \[ och \] runt dom orden.

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

## #7 — LarsG, 2003-09-25T15:37Z

section är ett reserverat ord i SQL. 

Flyttas från ASP

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

## #8 — Fredde Mannen, 2003-09-25T19:26Z

> **LarsG skrev:**
>
> section är ett reserverat ord i SQL. 
> 
> Flyttas från ASP

Då måste det bara vara ett reserverat ord i vissa relationsdatabaser, eftersom det funkar fint i MySQL....
 Nåja jag får döpa om den och se om det funkar bättre!!

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

## #9 — Fredde Mannen, 2003-09-25T20:48Z

Funkade.... :)

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

---

Tråden på webben: https://www.webforum.nu/amne/databaser-sql/86945-fel-i-insert-into-uttryck
