将 nvarchar 值 'Category' 转换为数据类型为 int 的列时发生语法错误,咋办?

IF NOT EXISTS (SELECT * FROM sysobjects WHERE Name = OBJECT_ID(N'[dbo].[Role]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Role](
[ID] [int] IDENTITY(1,1) NOT NULL,
[RoleName] int NULL,
CONSTRAINT [PK_Role] PRIMARY KEY CLUSTERED 
(
[ID] ASC
)
) ON [PRIMARY] 

达令说
浏览 214回答 2
2回答

慕婉清6462132

IF NOT EXISTS (SELECT * FROM sysobjects WHERE Name = 'Role' AND type = 'U')BEGINCREATE TABLE [dbo].[Role]([ID] [int] IDENTITY(1,1) NOT NULL,[RoleName] int NULL,CONSTRAINT [PK_Role] PRIMARY KEY CLUSTERED ([ID] ASC)) ON [PRIMARY]

慕慕森

参数类型错误,将 public bool Update(string id 换成 public bool Update(int id 即可。当然,函数调用也要变更,这是个int类型而不是字符串类型。
打开App,查看更多内容
随时随地看视频慕课网APP