Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have saved login time correctly. But, While updating logout time all the values from previous rows also updating in logout. If given Id in where condition it not even saving

What I have tried:

Public Function logoutpage(ByVal iEmpID As Integer) As Integer
     Try
         Dim sSql As String = ""
         sSql = " UPDATE employee.tblcheck SET " &
                  " OutTime='" & DateTime.Now.ToString("hh:mm:ss") & "'"
         Dim ireturn As Integer = execute(sSql)
     Catch ex As Exception
     End Try
 End Function





Private Sub btnlogout_Click(sender As Object, e As EventArgs) Handles btnlogout.Click
       Dim objlogout As New Attendance
       Dim iresult As Integer = objlogout.logoutpage(0)
       Response.Redirect("LoginPage.aspx")
   End Sub
Posted
Updated 16-Mar-17 2:29am
Comments
CHill60 16-Mar-17 7:54am    
You have to use the employee id otherwise you will logout everyone!
Never use concatenated strings for your sql - use SqlParameter instead

Public Function logoutpage(ByVal iEmpID As Integer) As Integer
        Try
            Dim sSql As String = ""
            sSql = " UPDATE employee.tblcheck SET " &
                     " OutTime='" & DateTime.Now.ToString("hh:mm:ss") & "'"
                     & " WHERE employee.tblcheck.EmployeeId = " & iEmpID.ToString
            Dim ireturn As Integer = execute(sSql)
        Catch ex As Exception
        End Try
    End Function


You'll need to substitute your actual employee id field in the WHERE clause.
 
Share this answer
 
v2
Comments
Member 13040174 16-Mar-17 8:11am    
Ya i did this,.. but if i given EmpID it not even displaying any time
F-ES Sitecore 16-Mar-17 8:13am    
What do you mean by not displaying any time? There is nothing in your code that displays anything.
Ummm...there's a problem with your design. What if the power fails or the PC crashes and there is no logout?? You really can't track it this way. Your database design only allows for tracking the last login and logout times. You have no historical record.

This isn't a code problem. This is a large design problem where you don't have a set of business rules that makes any sense.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900