日期:2014-05-18  浏览次数:20625 次

将数据类型 char 转换为 smallint 时出错
CREATE   PROCEDURE   [UPDATE修改文章属性]
(@id_1   [int],
  @标题_2   [nvarchar](50),
  @f_id_3   [smallint],
  @s_id_4   [smallint],
  @内容_5   [ntext],
  @关键字_6   [nvarchar](100),],
  @作者_7   [nvarchar](50))

AS   UPDATE   [MyDb].[dbo].[内容表]  

SET     [标题]   =   @标题_2,
  [f_id]   =   @f_id_3,
  [s_id]   =   @s_id_4,
  [内容]   =   @内容_5,
  [关键字]   =   @关键字_6,
  [作者]   =   @作者_7  

WHERE  
(   [id]   =   @id_1)
GO

==================================================
当我要将s_id字段更新为null时,怎么处理?请大家帮忙。

------解决方案--------------------
--你修改下存储过程

ALTER PROCEDURE [UPDATE修改文章属性]
(@id_1 [int],
@标题_2 [nvarchar](50),
@f_id_3 [smallint],
@s_id_4 [smallint],
@内容_5 [ntext],
@关键字_6 [nvarchar](100),
@作者_7 [nvarchar](50))

AS UPDATE [MyDb].[dbo].[内容表]

SET [标题] = @标题_2,
[f_id] = @f_id_3,
[s_id] = case when @s_id_4 = -999 then NULL else @s_id_4 end,
[内容] = @内容_5,
[关键字] = @关键字_6,
[作者] = @作者_7

WHERE
( [id] = @id_1)
GO


--ASP改为这段代码看看会有什么错误?
id = 1
title = "标题 "
f_id = 8
s_id = -999
content = "内容 "
keyword = "关键字 "
zz = "作者 "