Ruby on Rails Monday, November 29, 2010

Hi, dear guys!
I have following super simple program
dbh=DBI.connect("DBI:SQLite3:barron.db")
sth=dbh.prepare("INSERT INTO WORDS VALUES(?,?,?)")

3.times{
sth.execute("1","2","3")
}

and it gives me error :
/Users/tsdeng/.rvm/gems/ruby-1.8.7-p302/gems/sqlite3-ruby-1.3.1/lib/sqlite3/statement.rb:41:in `bind_param': library routine called out of sequence (SQLite3::MisuseException)
from /Users/tsdeng/.rvm/gems/ruby-1.8.7-p302/gems/sqlite3-ruby-1.3.1/lib/sqlite3/statement.rb:41:in `bind_params'
from /Users/tsdeng/.rvm/gems/ruby-1.8.7-p302/gems/sqlite3-ruby-1.3.1/lib/sqlite3/statement.rb:37:in `each'
from /Users/tsdeng/.rvm/gems/ruby-1.8.7-p302/gems/sqlite3-ruby-1.3.1/lib/sqlite3/statement.rb:37:in `bind_params'
from /Users/tsdeng/.rvm/gems/ruby-1.8.7-p302/gems/dbd-sqlite3-1.2.5/lib/dbd/sqlite3/statement.rb:71:in `bind_params'
from /Users/tsdeng/.rvm/gems/ruby-1.8.7-p302/gems/dbi-0.4.5/lib/dbi/handles/statement.rb:115:in `execute'
from words.rb:53
from words.rb:49:in `each'
from words.rb:49


I can avoid this error by not using prepared statement. But I want to use it!!! T_T

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment