Thread: table update
View Single Post
Old 12-04-2006, 02:34 AM
digitiger digitiger is offline
Senior Member
Join Date: Jan 2001
Posts: 716
Default RE: table update

First of all what database do you use?

Secondly you dont have to get the recordcount of the table and then run the loop because recordcount is not really supported by most of the database and sometimes it does not gives you the correct number of records

instead you can run the loop as follows:

while not table1.eof do

blah blah blah....

Secondly, if you need to update all the records with particular value in given field then simplest and fastest way to do that is using an update query.

you can just add a query component and write its sql as follows:

'Update ' + quotedStr(Table1.tablename) + ' set Age = ' + quotedStr(Age) + ' where ID = ' + QuotedStr(CurrID)

Above assumes that the age as well as ID fields are string types else you will have to ommit the quotedStr() part .

and when you want to execute the above statement just say


In nutshell the final SQL statement should look like the following (supposing table name is AgeData you want to set the age to 'THIRTY' for all thE IDs with values as "ID01abc'

Update AgeData set Age = "Thirty" where ID = "ID01abc"

Hope it helps and if it does then do accept the answere
Reply With Quote