From: gavin@... Date: 2005-02-10T02:40:05+09:00 Subject: Re: DBI INSERT with variables I'm on WinXP, using Ruby 1.8.2 with DBI to connect to a MSSQL2k DB via ODBC DSN. The following works for me: LIVE_DB_DSN_LOGIN = [ 'dbi:ODBC:LiveServer', 'myusername', 'mypassword' ] begin require 'dbi' dbh = DBI.connect( *LIVE_DB_DSN_LOGIN ) add_article = dbh.prepare( <<-ENDSQL INSERT INTO tblArticles ( title, date_updated, author ) VALUES ( ?, #{Time.at(0).to_sql}, '#{AUTHOR}' ) ENDSQL ) #...later add_article.execute( title ) rescue DBI::DatabaseError => e puts "An error occurred" puts "Error code: #{e.err}" puts "Error message: #{e.errstr}" ensure #close out statements add_article.finish #unplug from the database dbh.disconnect end