Syntax error in query. Incomplete query clause (1 Viewer)

H

Hemmli

Guest
I am really stuck. I have spent two days searcinh different forums trying to solve my problem. I am trying to create an UPDATE q to my Access database. But I get either the: "Syntax error in query. Incomplete query clause" or "Syntax error in UPDATE query".

First of all here's the URL: www.innotec-as.no/login/Kunder
Login U/P either: "alfen" or "thomas".

The page opening up shows the user info, U/P and adress.
viewing the information is working perfectly - but editing it..no way.

When editing and submiting the data the above errors occour.
Try that and you'll also see the SQL I am trying to execute.
The CODE is as follows:

SQLtemp = "UPDATE 'Brukere' SET"
SQLtemp = SQLtemp & " 'navn' = '" & request("Navn") & "', "
SQLtemp = SQLtemp & " 'epst' = '" & request("Epst") & "', "
SQLtemp = SQLtemp & " 'Pass' = '" & request("Pass") & "', "
SQLtemp = SQLtemp & " 'Firma' = '" & request("Firma") & "', "
SQLtemp = SQLtemp & " 'BAdresse' = '" & request("BAdresse") & "', "
SQLtemp = SQLtemp & " 'BPostAdr' = '" & request("BPostAdr") & "', "
SQLtemp = SQLtemp & " 'PAdresse' = '" & request("PAdresse") & "', "
SQLtemp = SQLtemp & " 'PPostAdr' = '" & request("PPostAdr") & "', "
SQLtemp = SQLtemp & "WHERE 'Bnavn' = '" & request("Bnavn") & "'"

Response.Write(SQLtemp)
Response.End()

conn.Execute(SQLtemp)
rs.Update[/COLOR]


The finished SQL statement looks like this:

UPDATE 'Brukere' SET 'navn' = 'Alf Byman', 'epst' = 'alf@baccara.no', 'Pass' = 'alfen', 'Firma' = '', 'BAdresse' = '', 'BPostAdr' = '', 'PAdresse' = 'sdfg', 'PPostAdr' = '', WHERE 'Bnavn' = 'alfen'

I have tried to user single quotes, doubble quotes, brackets etc. nothing works.

The code I use for connection is as follows:

<!--#include file="../adovbs.inc"-->
<%
dim conn, rs, SQLtemp

' DSNless connection to Access Database
set conn = server.CreateObject ("ADODB.Connection")
rs="DRIVER={Microsoft Access Driver (*.mdb)}; "
rs=rs & "PWD=uralfjellet; DBQ=" & server.mappath("../../../../db/kunder.mdb")

conn.Open rs

I'll be very HAPPY for some expert help on this.
 
H

Hemmli

Guest
Added

Here is a simpyfied version of the code in question.
With the same error..:

<% @ Language = VBScript %>
<%
Option Explicit
With Response
.Buffer = True
.Expires = 0
.Clear
End With
on error goto 0

Dim bruker : bruker = request("bruker") ' USER ID

Dim brpass : brpass = request("brpass") ' User Password
dim brnavn : brnavn = request("brnavn") ' User Name

Dim a, z, c, r, snr, sql : sql = ""
If bruker <= 0 then
bruker = 1
End if

' CHOOSE TO UPDATE OR JUST SHOW INFO
If brnavn <> "" And brpass <> "" Then
sql = "UPDATE 'Bruker' SET 'Bnavn' = '" & request(brnavn) & "', 'Badr' = '" & request(brpass) & "' WHERE BID = " & bruker & ";"
brnavn = ""
brpass = ""
Else
sql = "SELECT BID, Bnavn, Badr FROM bruker WHERE BID LIKE '%" &bruker & "%';"
End If

set c = server.createobject("adodb.connection")
c.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("../../../../db/medlem.mdb")
set r = server.createobject("adodb.recordset")
r.open sql, c
on error resume next

%><html>
Strings:
From FORM: <%=bruker%> - <%=brnavn%> - <%=brpass%> <br>
From DB: <%=r(0)%> - <%=r(1)%> - <%=r(2)%> <br>
Form Action: <%=action%>

<form action="MyTest.asp" method="post">
<label>Brukernavn
<input type="text" name="brnavn" value="<%=r(1)%>">
</label>
<label>Adresse
<input type="text" name="brpass" value="<%=r(2)%>">
<input name="bruker" type="hidden" value="<%=r(0)%>">
</label>
<p>
<label>
<input type="Submit" name="Submit" value="Submit">
</label>
</p>
</form>

<%




'r.close : c.close : set r = nothing : set c = nothing


%>
 

Users who are viewing this thread

Top Bottom