Faild to update sqlite database using activerecord

Hi all,
I was trying to update the JIS-encoded text in the databse to UTF-8
text but failed (For simplicity, I use "hello" & "world" in the test
program below). Please point me the mistake I made here. Thanks.

#using sqlite
ActiveRecord::Base::establish_connection
(:adapter=>"sqlite3",:dbfile=>"the.db")

#try to do the update but failed
rowid = 72 #it is the default unique ID in sqlite
Basic.find(:all , :select=>"rowid , event_name ,text ",
                   :conditions=>["rowid = ?",rowid]).each do |o|

                puts "before modify"
                puts o.event_name
                puts o.text
                o.event_name = "hello"
                o.text = "world"
                puts "after modify before save"
                puts o.event_name
                puts o.text
                o.save
                #o.update_attribute(:event_name,"hello")
        end
        #confirm
        Basic.find(:all , :select=>"rowid , event_name ,text ",
                              :conditions=>["rowid = ?",rowid]).each
do |o|
                puts "after save"
                puts o.rowid
                puts o.event_name
                puts o.text
        end

output Log :

-->before modify
>⒏Ⅲ罐る?L1B2nrDJ0楦?6I!Aん赏发!!?贽罂?Eg!A?
B?L1B2?Jk楣|ん赏发??贽罂?Eg?J6Ah,@d(:?}踌耷?>@7<T?@i?M?D6国L1B2M;OB?L\;X?c<T10?M?|楦?
I r;O a??c-DJNJ3F.rDI&?

-->after modify before save
hello
world

-->after save
72
>⒏Ⅲ罐る?L1B2nrDJ0楦?6I!Aん赏发!!?贽罂?Eg!A?
B?L1B2?Jk楣|ん赏发??贽罂?Eg?J6Ah,@d(:?}踌耷?>@7<T?@i?M?D6国L1B2M;OB?L\;X?c<T10?M?|楦?
Ir;Oa??c-DJNJ3F.rDI&?

Basic.find(:all , :select=>"rowid , event_name ,text ",
                   :conditions=>["rowid = ?",rowid]).each do |o|

Is rowid your primary key (and if so have you told active record that
it is) ? if not then your save is failing because you haven't selected
the primary key. Also check that you don't have any failing
validations

Fred

I forgot to specify the primary key as rowid.

Thanks , Fred.