Double entry on one button click ,asp.net c# webform

Analyst_SQL 3,576 Reputation points
2021-06-14T11:42:30.127+00:00

I am currentyl facing issue ,that user click one time on Button ,then entry get inserted two time in system, so i want to set interval of 4 second between entries,mean that if User insert time 11:15:14 ,if user try to save another entry then it take 4 second ,means that next entry save on 11:15:19.

below is code

 ALTER PROCEDURE [dbo].[spInsertPorderder]   
     -- Add the parameters for the stored procedure here  
     @Codeitem int,  
     @OrderNo int,  
     @prdqty int,  
     @IDWoker int,  
     @EntryDate date,  
     @FID int,  
      
     @Weight int,  
     @SecID int,  
     @Rmk varchar (50),  
     @ETime time(7),  
     @BrefNo varchar (50),  
     @IPAddress [varchar](50) ,  
     @Gweigth int,  
     @OID int output  
           
          
 AS  
 BEGIN  
          
     SET NOCOUNT ON;  
      
      
         IF NOT EXISTS   
 (  
    SELECT ETIME, IPAddress,EntryDate  FROM Probale  
    WHERE ETIME = @ETIME and IPAddress = @IPAddress and EntryDate=@EntryDate and Codeitem=@Codeitem  
 )  
 Begin   
         insert into Probale(Codeitem,OrderNo,prdqty,IDWokrer,EntryDate,FID,Weigth,SecID,Rmk,ETime,BrefNo,IPAddress,Gweigth )   
     values(@Codeitem,@OrderNo,@prdqty,@IDWoker,@EntryDate,@FID,@Weight,@SecID,@Rmk,@ETime,@BrefNo,@IPAddress,@Gweigth )  
     set @OID=SCOPE_IDENTITY()  
 end  
 end  

105358-double.txt

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Developer technologies | ASP.NET | Other
SQL Server | Other
{count} votes

Answer accepted by question author
  1. AgaveJoe 30,406 Reputation points
    2021-06-15T10:50:20.06+00:00

    As explained in your duplicate thread, use JavaScript and standard ASP.NET properties to disable the submit button. The user will not be able to double click the button.

     OnClientClick="this.disabled = true;"   
     UseSubmitBehavior="false"   
    

    Also, redirect on the server to a confirmation page or the same page. This is called the Post/Redirect/Get pattern and it solve this very common programming problem.


5 additional answers

Sort by: Most helpful
  1. Suwandi 1 Reputation point
    2021-06-21T14:04:50.243+00:00

    Add new datetime column or change current time column to datetime.
    Next, if you want get time only, you can cast it to time.
    SELECT Cast(DateColumn as Time) as TIMEONLY FROM THETABLE

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.