webForumDet fria alternativet

Updateproblem

2 svar · 209 visningar · startad av WebbisNet

WebbisNetMedlem sedan feb. 20032 027 inlägg
#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

LarsGMedlem 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

lazatMedlem sedan mars 2001308 inlägg
#3

samt missat en ' på efter 'txtStart,

127 ms totalt · 3 externa anrop · v20260731065814-full.30151723
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
124 ms — hämta tråd, inlägg och bilagor (db)