今天有网友问Insus.NET,他公司有一个小程序,已经被编译为DLL,不知怎样去添加一个小功能。就是需要限制用户上传文件个数。
Insus.NET看过他的程序与数据库之后,决定着手在数据库去修改。
请看原添加的存储过程:
ALTER PROCEDURE [dbo].[usp_UploadFile_Insert]
(
@OldFileName [nvarchar](130),
@NewFileName [nvarchar](130),
@Author [nvarchar](50)
)
AS
INSERT INTO [dbo].[UploadFiles] ([OldFileName],[NewFileName],[Author])
VALUES (@OldFileName,@NewFileName,@Author)
(
@OldFileName [nvarchar](130),
@NewFileName [nvarchar](130),
@Author [nvarchar](50)
)
AS
INSERT INTO [dbo].[UploadFiles] ([OldFileName],[NewFileName],[Author])
VALUES (@OldFileName,@NewFileName,@Author)
Insus.NET为他修改的存储过程:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_UploadFile_Insert]
(
@OldFileName [nvarchar](130),
@NewFileName [nvarchar](130),
@Author [nvarchar](50)
)
AS
--下面部分是Insus.NET:http://insus.cnblogs.com 添加代码
SELECT [UploadFileId] FROM [dbo].[UploadFiles] WHERE [Author] = @Author
IF @@ROWCOUNT = 5
BEGIN
RAISERROR(N'你最多只能上传5个文件进行分析,你可以尝试删除旧文件,再上传。',16,1)
RETURN
END
INSERT INTO [dbo].[UploadFiles] ([OldFileName],[NewFileName],[Author])
VALUES (@OldFileName,@NewFileName,@Author)
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_UploadFile_Insert]
(
@OldFileName [nvarchar](130),
@NewFileName [nvarchar](130),
@Author [nvarchar](50)
)
AS
--下面部分是Insus.NET:http://insus.cnblogs.com 添加代码
SELECT [UploadFileId] FROM [dbo].[UploadFiles] WHERE [Author] = @Author
IF @@ROWCOUNT = 5
BEGIN
RAISERROR(N'你最多只能上传5个文件进行分析,你可以尝试删除旧文件,再上传。',16,1)
RETURN
END
INSERT INTO [dbo].[UploadFiles] ([OldFileName],[NewFileName],[Author])
VALUES (@OldFileName,@NewFileName,@Author)