尝试在我的表中执行插入语句时,出现此错误:
数据转换失败。[ OLE DB 状态值(如果已知)= 2 ]
我已经在网上完成了我的研究,似乎无法找到解决这个问题的答案。
插入语句如下所示:
INSERT INTO [Beverages] (BeverageID, ParentBeverageID, Name, PreferredRecipeVersion,
SpecificCustomerID, AcceptabilityRating, ShowBeverage, Availability,
Family, EngagedPriority, SmilePriority, Collections)
VALUES (1475614, 1475633, 'Caffeine-free', 3, 1, 0, 1, 1, 'A', 'NULL', 1, 'UK')
我最初构建的表(确实创建了它)如下所示:
string beverages = "CREATE TABLE [Beverages]([BeverageID] INT NOT NULL,[ParentBeverageID] INT, [Name] NVARCHAR(40) NOT NULL,[PreferredRecipeVersion] INT NOT NULL DEFAULT(1),[SpecificCustomerID] INT NOT NULL DEFAULT(0),[AcceptabilityRating] INT NOT NULL DEFAULT(0),[ShowBeverage] INT NOT NULL DEFAULT(1),[Availability] INT NOT NULL DEFAULT(1),[Family] NVARCHAR(1),[EngagedPriority] INT,[SmilePriority] INT NOT NULL DEFAULT(0), [Collections] NVARCHAR(50) NOT NULL);";
string beverages1 = "ALTER TABLE [Beverages] ADD CONSTRAINT [PK__Beverages__000000000000134A] PRIMARY KEY ([BeverageID]);";
string beverages2 = "CREATE INDEX [PK_BeverageID] ON [Beverages] ([BeverageID] ASC);";
db.ExecuteSqlCommand(beverages, null, __gulfstreamDataConn);
db.ExecuteSqlCommand(beverages1, null, __gulfstreamDataConn);
db.ExecuteSqlCommand(beverages2, null, __gulfstreamDataConn);
我不知道是什么导致了这个问题,但提前感谢您的帮助!