I have a web page utilizing asp, vbscript, msaccess 2000.
Here is my code:
First version (this works fine):
<%
for each Field in rs.fields
for k = 0 to UBound(arrSand)
if Field.name = arrSand(k) then
SQL = "UPDATE sand SET " & Field.name & "
= 'True' WHERE(sand.personid = " & varNewID & " "
Response.Write(SQL)
connSand.execute(SQL)
end if
next
next
%>
But then I add an "else" in this second version, which I would prefer to use and it gets stuck on 2nd UPDATE syntax and I get error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
This is the echo of the 2nd UPDATE statement that it hangs on:
UPDATE sand SET all = 'False' WHERE(sand.personid = 308)
<%
for each Field in rs.fields
for k = 0 to UBound(arrSand)
if Field.name <> "personid" then
if Field.name = arrSand(k) then
SQL = "UPDATE sand SET " & Field.name & "
= 'True' WHERE(sand.personid = " & varNewID & " "
Response.Write(SQL)
connSand.execute(SQL)
else
SQL = "UPDATE sand SET " & Field.name & "
= 'False' WHERE(sand.personid = " & varNewID & " "
Response.Write(SQL)
connSand.execute(SQL)
end if
end if
next
next
%>
What's the problem? Can UPDATE not be done in an if-else loop like this? By the way, both loops are utilized during the UPDATE (ie: there will always be values that go into the "if" and there will always be values that go into the "else". Any help is appreciated. P.S. If i posted to wrong forum, sorry, i don't know if this is asp, msaccess or sql issue.
Thanks in advance for ANY enlightenment
Here is my code:
First version (this works fine):
<%
for each Field in rs.fields
for k = 0 to UBound(arrSand)
if Field.name = arrSand(k) then
SQL = "UPDATE sand SET " & Field.name & "
= 'True' WHERE(sand.personid = " & varNewID & " "
Response.Write(SQL)
connSand.execute(SQL)
end if
next
next
%>
But then I add an "else" in this second version, which I would prefer to use and it gets stuck on 2nd UPDATE syntax and I get error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
This is the echo of the 2nd UPDATE statement that it hangs on:
UPDATE sand SET all = 'False' WHERE(sand.personid = 308)
<%
for each Field in rs.fields
for k = 0 to UBound(arrSand)
if Field.name <> "personid" then
if Field.name = arrSand(k) then
SQL = "UPDATE sand SET " & Field.name & "
= 'True' WHERE(sand.personid = " & varNewID & " "
Response.Write(SQL)
connSand.execute(SQL)
else
SQL = "UPDATE sand SET " & Field.name & "
= 'False' WHERE(sand.personid = " & varNewID & " "
Response.Write(SQL)
connSand.execute(SQL)
end if
end if
next
next
%>
What's the problem? Can UPDATE not be done in an if-else loop like this? By the way, both loops are utilized during the UPDATE (ie: there will always be values that go into the "if" and there will always be values that go into the "else". Any help is appreciated. P.S. If i posted to wrong forum, sorry, i don't know if this is asp, msaccess or sql issue.
Thanks in advance for ANY enlightenment