You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by "Heath, Terry" <te...@ttu.edu> on 2005/03/23 20:46:24 UTC
Problem with image data type in ms sql server and .net ibatis
Hi -
I get this error:
UnitTesting.DataLayerTests.PAF_ATTACHMENTS_Create :
System.Data.SqlClient.SqlException : Operand type clash: nvarchar is
incompatible with image
When trying to insert a row into the database. I've got a column with
data type = image, and a property (tied to the column in the datamap)
with type byte[].
I don't know what I should set as the nullValue for the byte[] property.
Here's the paramater map and the insert statement:
<parameterMaps>
<parameterMap id="InsertPAF_ATTACHMENTSParam"
class="PAF_ATTACHMENTS">
<parameter property="TransNo" nullValue="-9999" />
<parameter property="ImageData" />
<parameter property="ContextType" />
<parameter property="FileName" />
<parameter property="UserID" />
<parameter property="FileSize" nullValue="-9999" />
<parameter property="Timestamp" nullValue="1/1/0001 12:00:00
AM" />
</parameterMap>
<parameterMap id="UpdatePAF_ATTACHMENTSParam"
extends="InsertPAF_ATTACHMENTSParam">
<parameter property="AttachmentID" nullValue="-9999" />
</parameterMap>
</parameterMaps>
<insert id="PAF_ATTACHMENTSCreate"
parameterMap="InsertPAF_ATTACHMENTSParam">
<selectKey property="AttachmentID" resultClass="Integer">
select cast(@@IDENTITY as int) as value
</selectKey>
insert into [PAF_ATTACHMENTS] (
TransNo,
ImageData,
ContextType,
FileName,
FileSize,
UserID,
Timestamp
) values (
?,
?,
?,
?,
?,
?,
?
) </insert>
Here's the relevant parts of the code:
Private _imageData() As Byte
...
Public Property ImageData() As Byte()
Get
Return Me._imageData
End Get
Set(ByVal Value As Byte())
Me._imageData = Value
End Set
End Property
If you know what I'm doing wrong, please help :)
Thanks!
Terry