我的表单上有几个字段,我需要在用户输入后将它们存储在名为dbo.UploadFilesProject
的表中。为此,我想使用存储过程。
数据库表中的列:
@ProjectId (int, Input, No default)
@FileName (varchar(75), Input, No default)
@FilePath (varchar(500), Input, No default)
@UploadedDate (date, Input, No default)
@IsActive (bit, Input, No default)
@UpdatedBy (varchar(75), Input, No default)
@ClientId (int, Input, No default)
请告诉我如何实施这些要求?
答案 0 :(得分:1)
要CREATE TABLE使用类似的内容(此表上可能还需要一些主键,PK必须包含一些唯一的列):
CREATE TABLE dbo.UploadFilesProject (
ID int IDENTITY (1,1),
ProjectId int,
FileName varchar(75),
FilePath varchar(500),
UploadedDate date,
IsActive bit,
UpdatedBy varchar(75),
ClientId int,
CONSTRAINT [PK_id] PRIMARY KEY CLUSTERED ([id] ASC) -- add some PK
)
然后CREATE PROCEDURE写数据:
CREATE PROCEDURE dbo.UploadFilesProjectFill
@ProjectId int,
@FileName varchar(75),
@FilePath varchar(500),
@UploadedDate date,
@IsActive bit,
@UpdatedBy varchar(75),
@ClientId int
AS
BEGIN
INSERT INTO dbo.UploadFilesProject VALUES
(@ProjectId, @FileName, @FilePath, @UploadedDate, @IsActive, @UpdatedBy, @ClientId)
END