0

我正在尝试使用 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 与 image 不兼容。

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]
4

1 回答 1

1

您收到错误是因为列 QOH 的类型为 Image,并且您正试图在该列中插入一个整数 (9)。

于 2013-07-19T18:53:37.450 回答