Guest User

Guest User

  • Tech Writer
  • 529
  • 41k

How To FetchData With Datetime i got this Error

Jun 23 2022 5:44 AM

USE [EmployeeDB]
GO
/****** Object:  StoredProcedure [dbo].[spMember]    Script Date: 6/23/2022 10:29:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spMember]  
(  
    @WorkerID INT = NULL,  
    @FirstName VARCHAR(50) = NULL,  
    @Worker VARCHAR(50) = NULL,  
    @Cnic VARCHAR(50) = NULL,
    @CardNumber VARCHAR(50) = NULL,
	@FlatNumber VARCHAR(50) = NULL,
	@Designation VARCHAR(50) = NULL,
	@Checkin datetime,
	@Checkout datetime,
    @ActionType VARCHAR(25)  
)  
AS  
BEGIN  
    IF @ActionType = 'SaveData'  
    BEGIN  
        IF NOT EXISTS (SELECT * FROM Member WHERE WorkerID=@WorkerID)  
        BEGIN  
            INSERT INTO Member (FirstName,Worker,Cnic,CardNumber,FlatNumber,Designation,Checkin,Checkout)  
            VALUES (@FirstName,@Worker,@Cnic,@CardNumber,@FlatNumber,@Designation,@Checkin,@Checkout)  
        END  
        ELSE  
        BEGIN  
            UPDATE Member SET Checkout=@Checkout WHERE WorkerID=@WorkerID  
        END  
    END  
    IF @ActionType = 'DeleteData'  
    BEGIN  
        DELETE Member WHERE WorkerID=@WorkerID  
    END  
    IF @ActionType = 'FetchData'  
    BEGIN  
        SELECT WorkerID AS Sn,FirstName,Worker,Cnic,CardNumber,FlatNumber,Designation,CAST (GETDATE() AS datetime) AS Checkin,CAST (GETDATE() AS datetime) AS Checkout FROM Member  
    END  
    IF @ActionType = 'FetchRecord'  
    BEGIN  
        SELECT WorkerID AS Sn,FirstName,Worker,Cnic,CardNumber,FlatNumber,Designation,CAST (GETDATE() AS datetime) AS Checkin,CAST (GETDATE() AS datetime) AS Checkout FROM Member   
        WHERE WorkerID=@WorkerID  
    END  
END  


Answers (5)