我试图使用nhibernate插入记录。这是我得到的错误(或者说我的测试控制台应用程序显示的消息。带错误标题的第二部分是捕获的异常):
NHibernate.GuitarStore assembly initialized.
NHibernate: INSERT INTO INVENTORY (TYPEID, BUILDER, MODEL, QOH, COST, PRICE,RECEIVED)
VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6); select SCOPE_IDENTITY();@p0 = 1 [Type:Int32 (0)], @p1 = 'Test Builder 2' [Type: String (4000)], @p2 = 'Test Model 2' [Type: String (4000)], @p3 = 9 [Type: Int32 (0)], @p4 = 2000 [Type: Decimal (0)], @p5 = 200 [Type: Decimal (0)], @p6 = 7/19/2013 7:35:51 PM [Type: DateTime (0)]
***** ERROR *****
could not insert: [NHibernate.GuitarStore.Common.Inventory][SQL: INSERT INTO INVENTORY (TYPEID, BUILDER, MODEL, QOH, COST, PRICE, RECEIVED) VALUES (?, ?, ?, ?,?, ?, ?); select COPE_IDENTITY()] - InnerExcepetion: Operand type clash: int is incompatible with image
查看生成的插入SQL,在我看来,这些值与它们各自的类型相匹配。我不知道哪个int与图像不兼容,如错误所示。
PS:我的类型图像数据库中没有任何列
编辑:这里是广告资源的架构:
CREATE TABLE [dbo].[Inventory](builder] [varchar](50) NULL, [model] [varchar](50) NULL,
[qoh] [image] NOT NULL,
[cost] [decimal](18, 0) NOT NULL,
[price] [decimal](18, 0) NOT NULL,
[received] [datetime] NULL,
[id] [int] IDENTITY(1,1) NOT NULL,
[typeid] [int] NOT NULL, CONSTRAINT [PK_Inventory_1] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY] TEXTIMAGE_ON PRIMARY]
答案 0 :(得分:1)
您收到错误,因为列QOH的类型为Image,并且您尝试在该列中插入一个整数(9)。