Forum: Ruby on Rails sqlserver image columns

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jebus (Guest)
on 2006-02-06 17:51
(Received via mailing list)
I am trying to upload word docs to an image column. I followed the
cookbook for how to upload files and it works on a MySQL db (upload
and download) on SQLServer however I get the following error
DBI::DatabaseError: Execute
    OLE error code:80040E07 in Microsoft OLE DB Provider for SQL Server
      Operand type clash: text is incompatible with image
    HRESULT error code:0x80020009

Also I when I try to retrieve one (I put one in with java), all I get
is numbers. It doesn't look it is being converted to binary.

Here is some my code
class Attachment < ActiveRecord::Base
def initialize (tmpfile)
       super()
	self.filename = tmpfile.original_filename
	self.content_type = tmpfile.content_type
	self.created = DateTime.now().strftime("%Y%m%d %I:%M")
	self.file = tmpfile.read
end

Here is how I am rendering the documents
send_data attachment.file, :filename => attachment.filename, :type =>
attachment.content_type
This topic is locked and can not be replied to.