使用c#.net在网页中动态地将值插入数据库

时间:2022-09-20 01:39:52

I have got to insert employee details in EditProfile page of my project, it should be like the employee who logs in can edit his profile and insert the details and once he inserts, data will get stored in database and next time he/she logs in, their details should get displayed in the home page depending on their respective user id and password.

我必须在我的项目的EditProfile页面中插入员工详细信息,它应该像登录的员工可以编辑他的个人资料并插入详细信息,一旦他插入,数据将存储在数据库中,下次他/她登录,他们的详细信息应该显示在主页中,具体取决于他们各自的用户ID和密码。

I have done most of the things, but im not able to get the employee name while inserting the data in edit profile... I mean to say that if one employee logs in and edits his/her profile, data gets saved in the database but not with the respective employee's name.

我已经完成了大部分工作,但是在编辑配置文件中插入数据时我无法获得员工姓名...我的意思是说如果一个员工登录并编辑他/她的个人资料,数据将保存在数据库中但没有相应员工的姓名。

I have tried a stored procedure to insert the values to employee data but I don't know where to use employee name in that.

我已经尝试过存储过程将值插入员工数据,但我不知道在哪里使用员工姓名。

Below is my stored procedure:

以下是我的存储过程:

ALTER PROCEDURE [dbo].[InsertProfile]
    @Full_Name nvarchar(50),
    @Add nvarchar(50),
    @M_Num bigint,
    @Mail_ID nvarchar(50),
    @B_Group nvarchar(50),

    @EmpID bigint OUTPUT

    AS

    Insert Into dbo.EmployeeData
    (
     FullName,
     Address,
     MobileNumber,
     EmailID,
     BloodGroup
    )
    Values 
    (@Full_Name,
     @Add,
     @M_Num,
     @Mail_ID,
     @B_Group
    )
    Select @EmpID = SCOPE_IDENTITY();

1 个解决方案

#1


1  

ALTER PROCEDURE [dbo].[UpdateProfile]

@FullName nvarchar(50),
@Address nvarchar(50),
@MobileNumber bigint,
@EmailID nvarchar(50),
@BloodGroup nvarchar(50),
@EmpName nvarchar(50)

AS


Update dbo.EmployeeData

Set FullName = @FullName,
Address = @Address,
MobileNumber = @MobileNumber,
EmailID = @EmailID,
BloodGroup = @BloodGroup


Where EmpName = @EmpName;

#1


1  

ALTER PROCEDURE [dbo].[UpdateProfile]

@FullName nvarchar(50),
@Address nvarchar(50),
@MobileNumber bigint,
@EmailID nvarchar(50),
@BloodGroup nvarchar(50),
@EmpName nvarchar(50)

AS


Update dbo.EmployeeData

Set FullName = @FullName,
Address = @Address,
MobileNumber = @MobileNumber,
EmailID = @EmailID,
BloodGroup = @BloodGroup


Where EmpName = @EmpName;