webForumDet fria alternativet
Logga in / Bli medlem

Updateproblem

Databaser & SQL

2 svar · 209 visningar · startad av WebbisNet

Medlem sedan feb. 20032 027 inlägg
Trådstart#1

Set conn = Server.CreateObject("ADODB.connection")
conn.Open connstr
tblstart = Request.Form("txtstart")
tblTopRight = Request.Form("txtTopRight")
tblBottom = Request.Form("txtBottom")
SQL="UPDATE Mainsite SET tblStart='txtStart, tblTopRight='txtTopRight', tblBottom='txtBottom'"
SQL = SQL & "(tblStart, tblTopRight, tblBottom)"
SQL = SQL & "VALUES(' " & txtStart & " ',' " & txtTopRight & " ',' " & txtBottom & " ')"
Conn.Execute(SQL)
Response.Redirect "../main.asp"

Vad är det som gör att koden funkar

Felet jag får är:
ADODB.Connection.1 error '80004005'

SQLState: 42000
Native Error Code: 1064
[TCX][MyODBC]You have an error in your SQL syntax near 'txtTopRight', tblBottom='txtBottom'(tblStart, tblTopRight, tblBottom)VALUES(' '' at line 1

/asp/Admin/db-conn/update-start.asp, line 12

Medlem sedan dec. 200012 464 inlägg
#2

Du har blandat ihop syntaxen för update och insert.

update t set c1 = 4711, c2 = 'MC' where pk = 12

är ett exempel på gilitig update-sats.

Flyttas från Mysql

Medlem sedan mars 2001308 inlägg
#3

samt missat en ' på efter 'txtStart,

263 ms totalt · 4 externa anrop · v20260731065814-full.51f67c91
131 ms — deklarationer (db)
0 ms — hämta statistik (cache)
130 ms — hämta tråd, inlägg och bilagor (db)
117 ms — ändringar (db)