---
title: "Sql update"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/72683-sql-update"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "dahlgren"
published: "2003-03-31T13:44:33.000Z"
updated: "2003-03-31T15:11:45.000Z"
replies: 12
views: 225
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/72683-sql-update"
---

# Sql update

## #1 — dahlgren, 2003-03-31T13:44Z

Hur ska jag göra om detta till en update sats? Någon som kan hjälpa mig? Gärna tillvägagånssättet så jag klarar av det själ ifall det skulle behövas flera gånger.

```
	Set RecSet = Server.CreateObject("ADODB.Recordset")
   Uppdatera = "SELECT * FROM login WHERE ID = " & Request.Form("dold") & " "
   RecSet.Open Uppdatera, Conn, adOpenStatic, adLockOptimistic 

	RecSet("adress") = Request.Form("adress")
	RecSet("telhem") = Request.Form("telhem")
	RecSet("mobil") = Request.Form("mobil")
	RecSet("email") = Request.Form("email")
	RecSet("icq") = Request.Form("icq")
	RecSet("msn") = Request.Form("msn")
```

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

## #2 — erka, 2003-03-31T13:52Z

UPDATE login SET Kolumnnamn = '"& Request.Form("XXX") &"',Kolumnnamn = '"& Request.Form("XXX") &"' ,Kolumnnamn = '"& Request.Form("XXX") &"' ,Kolumnnamn = '"& Request.Form("XXX") &"' ,Kolumnnamn = '"& Request.Form("XXX") &"' ,Kolumnnamn = '"& Request.Form("XXX") &"'  WHERE ID = "& Request.Form("dold") &"

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

## #3 — Engine^, 2003-03-31T13:56Z

```
Uppdatera = "UPDATE login SET adress = '" & Request.Form("adress") & "', telhem = '"& Request.Form("telhem") & _
  "', mobil = '" & Request.Form("mobil") & "', email = '" & Request.Form("email") & _
  "', icq = " & Request.Form("icq") & ", msn = '" & Request.Form("msn") & _
  "' WHERE ID = " Request.Form("dold")

Conn.Execute Uppdatera, , adExecuteNoRecords
```

Dvs:
UPDATE *tabellnamn*
SET *kolumnnamn1* \= *värde*, *kolumnnamn2* \= *värde*, ..., *kolumnnamn*n = *värde*
WHERE *kolumnnamn* \= *värde*

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

## #4 — dahlgren, 2003-03-31T14:21Z

När jag prövar Engine^s kod dyker detta upp
Microsoft VBScript compilation error '800a0401' 

Expected end of statement 

/dweb/intern/adresser/uppdat_adr.asp, line 12 

"' WHERE ID = " Request.Form("dold")
\----------------^

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

## #5 — m_soderlund, 2003-03-31T14:23Z

Ett missat &. Sök alltid på Google om du inte hittar felet direkt.

```
Uppdatera = "UPDATE login SET adress = '" & Request.Form("adress") & "', telhem = '"& Request.Form("telhem") & _
  "', mobil = '" & Request.Form("mobil") & "', email = '" & Request.Form("email") & _
  "', icq = " & Request.Form("icq") & ", msn = '" & Request.Form("msn") & _
  "' WHERE ID = " [b]&[/b] Request.Form("dold")

Conn.Execute Uppdatera, , adExecuteNoRecords
```

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

## #6 — dahlgren, 2003-03-31T14:31Z

Tack, tycker att det är helt omöjligt att hålla kolla på fnuttar och &-tecken

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

## #7 — Engine^, 2003-03-31T14:34Z

Aaargh... missade sista &-tecknet... typiskt  x(

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

## #8 — dahlgren, 2003-03-31T14:47Z

Nu händer det konstiga saker här. När jag kör koden nedan så laddas sidan om hela tiden. Lyckas inte se varför, misstänker att det har med min if-sats att göra. Nån som ser felet?

```
<%
Uppdatera = "UPDATE login SET adress = '" & Request.Form("adress") & "', telhem = '"& Request.Form("telhem") & _
  "', mobil = '" & Request.Form("mobil") & "', email = '" & Request.Form("email") & _
  "', icq = " & Request.Form("icq") & ", msn = '" & Request.Form("msn") & _
  "' WHERE ID = " & Request.Form("dold")

	if request.form("oldpwd")= Session("Password")and request.form("newpwd")=request.form("newpwd2") Then
		if not request.form("newpwd")="" then
		upp= "update login SET Password= '" & Request.Form("newpwd") & "' WHERE ID = " & Request.Form("dold")
		dim strpwd
		strpwd="true"
		end if
	else
	response.write "De lösenord du angav stämmer inte."
	end if
Conn.Execute Uppdatera, , adExecuteNoRecords
	Conn.Close
 	
 	response.redirect "adress.asp?m=ledare&pwd=" & strpwd
	 %>
```

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

## #9 — m_soderlund, 2003-03-31T14:50Z

Du kanske skulle sätta *response.redirect "adress.asp?m=ledare&pwd=" & strpwd* efter första end if-blocket?
Som det är nu skickas besökaren vidare oavsett om lösenordet stämde eller ej.

/r Ser nu att hela din kod är lite grötig, men jag har inte tid att koda om den. Kanske nån annan får tid? Lycka till!

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

## #10 — m_soderlund, 2003-03-31T14:56Z

Kanske så här:

```
<%
Uppdatera = "UPDATE login SET adress = '" & Request.Form("adress") & "', telhem = '"& Request.Form("telhem") & _
  "', mobil = '" & Request.Form("mobil") & "', email = '" & Request.Form("email") & _
  "', icq = " & Request.Form("icq") & ", msn = '" & Request.Form("msn") & _
  "' WHERE ID = " & Request.Form("dold")

	if request.form("oldpwd")= Session("Password")and request.form("newpwd")=request.form("newpwd2") Then
		if not request.form("newpwd")="" then
		upp= "update login SET Password= '" & Request.Form("newpwd") & "' WHERE ID = " & Request.Form("dold")
		dim strpwd
		strpwd="true"
		end if
Conn.Execute Uppdatera, , adExecuteNoRecords
	Conn.Close
 	
 	response.redirect "adress.asp?m=ledare&pwd=" & strpwd
	else
	response.write "De lösenord du angav stämmer inte."
	end if
	 %>
```

...?

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

## #11 — dahlgren, 2003-03-31T15:04Z

Nu fungarer det lite bättre, fast lösenordet ändras inte.

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

## #12 — m_soderlund, 2003-03-31T15:10Z

Det står ju *upp="..sql-koden"*, men det ska ju vara *uppdatera="..sql-koden"*. Det gäller att inte vara trött eller slarvig när man kodar!

Jag lyckades med att koda min förra nya sajt (version 3 av Dileno.) i princip varje natt fram till 02.00, från i slutet av augusti -02 till 24 november - 02. Jag gick oftast upp mellan 07 och 09 också.. Koncentration behövs för att det ska gå bra! :)

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

## #13 — m_soderlund, 2003-03-31T15:11Z

Den färdiga koden borde alltså se ut så här:

```
<%
Uppdatera = "UPDATE login SET adress = '" & Request.Form("adress") & "', telhem = '"& Request.Form("telhem") & _
  "', mobil = '" & Request.Form("mobil") & "', email = '" & Request.Form("email") & _
  "', icq = " & Request.Form("icq") & ", msn = '" & Request.Form("msn") & _
  "' WHERE ID = " & Request.Form("dold")

	if request.form("oldpwd")= Session("Password")and request.form("newpwd")=request.form("newpwd2") Then
		if not request.form("newpwd")="" then
		[b]uppdatera[/b]= "update login SET Password= '" & Request.Form("newpwd") & "' WHERE ID = " & Request.Form("dold")
		dim strpwd
		strpwd="true"
		end if
Conn.Execute Uppdatera, , adExecuteNoRecords
	Conn.Close
 	
 	response.redirect "adress.asp?m=ledare&pwd=" & strpwd
	else
	response.write "De lösenord du angav stämmer inte."
	end if
	 %>
```

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/72683-sql-update
