今天学习了一下CKEditor。。。果然很好用啊。。。最近做的新闻管理比较头疼。。。有点吃力啊。。。ado.net真的这么难么?
CREATE PROCEDURE insertNews
-- Add the parameters for the stored procedure here
@title nvarchar(100), --新闻标题
@content TEXT, --新闻内容
@pubUser NVARCHAR(50), --发布人
@catids varchar(200), --新闻类别列表,用“:”分割
@error nvarchar(200) OUTPUT --用来返回错误信息
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @newsid int --新闻id
declare @catid varchar(10) --新闻类别id
declare @pos int --类别列表中分隔符":"的位置
begin transaction
begin try
insert into newscontent (title,[content],pubuser)values(@title,@content,@pubUser)
set @newsid=@@identity --获取刚写入的新闻的ID标识
while(len(@catids) > 0)
begin
set @pos = charindex(':',@catids)
if @pos <> 0
begin
set @catid=substring(@catids,1,@pos-1)
set @catids = substring(@catids,@pos+1,len(@catids)-@pos)
end
else
begin
set @catid=@catids
set @catids=''
end
insert into NewsCategory(newsid,catid)values(@newsid,cast(@catid as int))
end
commit transaction
return 0 --表示写入成功
END TRY --end try和begin catch之间不能有其他语句
begin catch
set @error = error_message()
rollback transaction
return -1 --表示写入失败
end catch
END
GO