This topic is locked

Update multiple records on the List page

10/13/2013 5:43:51 AM
ASPRunnerPro General questions
K
kleanthis author

I want to update multiple records on the list page, and I try to use the update button that described in the manual, but it doesn't work. I get a syntax error on line 5 (sql = "Update employees set ReportsTo='Bob Smith' )
This is the code on the manual.
**dim sql, i

if keys.Count>0 then

for i=0 to keys.Count-1

' set ReportsTo field to 'Bob Smith'

sql = "Update employees set ReportsTo='Bob Smith'


where KeyField=" & keys(i)(KeyField)

dbConnection.Execute sql

next

result("txt") = "Records were updated."

end if
That is the code that I am using.
dim sql, i

if keys.Count>0 then

for i=0 to keys.Count-1

' set ReportsTo field to 'Bob Smith'

sql = "Update SchoolCode set SchoolCode='200057'"

where "KeyField=" & keys(i)(200056)

dbConnection.Execute sql

next

result("txt") = "Records were updated."

end**if
I have two questions:

  1. where is my mistake?
  2. can I selected records and then to update a field on the fly like it described in the topic

    http://www.asprunner.com/forums/topic/21119-update-multiple-records

admin 10/13/2013

Step one - check your code for syntax errors. There is a built-in syntax checker in ASPRunnerPro.
Step two - make sure all table and field names are correct in your code.

K
kleanthis author 10/13/2013



Step one - check your code for syntax errors. There is a built-in syntax checker in ASPRunnerPro.
Step two - make sure all table and field names are correct in your code.


Hi, again
I do the built-in syntax checker in ASPRunnerPro and I get an error in the code that I get from the manual, as I show in the previus post.

I also double-check the field names and are ok.

My problem is when I press the update button it does nothing!

admin 10/13/2013

Are you saying you getting error right after pasting code from the manual or after you applied your changes?

K
kleanthis author 10/14/2013



Are you saying you getting error right after pasting code from the manual or after you applied your changes?



I getting error after pasting code from the manual.

The error is

"Microsoft VBScript compilation error: Unterminated string constant in line"
I have ASPRunner 7.2

lefty 10/14/2013



I getting error after pasting code from the manual.

The error is

"Microsoft VBScript compilation error: Unterminated string constant in line"
I have ASPRunner 7.2


I've had same issue was the single quotes on integer field will work if text field thogh. Try in line 5 sql = "Update SchoolCode set SchoolCode=200057" and keyfield looks wrong is 20056 your key field? on line 6 . Should only be keyfield for this type statement. Make sure to take out - line end in manual for testing.
As a workaround for 2nd question . Use Inline edit on list page . Check the records to update and click inline edit button ; fill data and click save all.

admin 10/14/2013

It looks like syntax checked doesn't understand multiline statements or there is syntax error in the manual
Instead of

sql = "Update employees set ReportsTo='Bob Smith' _

where KeyField=" & keys(i)(KeyField)


Use

sql = "Update employees set ReportsTo='Bob Smith' where KeyField=" & keys(i)(KeyField)


Both occurrences of KeyField need to be replaced with key column name