Can't Update my User Table "Hours" "Minutes" "Seconds"
from the current value of the timer where it has stopped
I used button to stop the time

Imports System.Data.OleDb

Public Class frmMain
    Public hh As Integer
    Public mm As Integer
    Public ss As Integer
    Public totalsec As Integer
    Public timercount As Integer
    Public temp As Integer
    Dim cnn3 = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Renz\Documents\Visual Studio 2012\Internet Cafe Billing System\Database\Database1.accdb")
    Dim sql1 As String
    Dim Command1 As New OleDbCommand
    Dim i2 As Integer


    Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Timer1.Enabled = True

    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        lbltime.Text = Date.Now.ToString("hh:mm tt") 'live clock
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
        frmLogin.Show()
    End Sub
    Private Sub btnEnd_Click(sender As Object, e As EventArgs) Handles btnEnd.Click

        lblend.Text = Format(Now, "hh:mm tt") 'get stop time'


        Try
            cnn3.Open()
            sql1 = "UPDATE Users SET Hours = '" & lblHours.Text & "', Minutes = '" & lblMinutes.Text & "', Seconds = '" & lblSeconds.Text & "'  WHERE ID = '" & frmLogin.txtUsername.Text & "'"
            Command1 = New OleDbCommand(sql1, cnn3)
            i2 = Command1.ExecuteNonQuery

        Catch ex As Exception
            frmLogin.ds = New DataSet 'reset dataset
            Timer2.Stop()
            cnn3.Close()
        End Try
    End Sub

    Private Sub lblRemaining_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
        If lblHours.Text.Length < 2 Then lblHours.Text = "0" & lblHours.Text '// format from "0" to "00"
        '// verify Hours.
        If lblHours.Text > "00" And lblMinutes.Text = "00" Then
            lblHours.Text -= 1
            lblMinutes.Text = "60"
        End If

        If lblMinutes.Text.Length < 2 Then lblMinutes.Text = "0" & lblMinutes.Text '// format from "0" to "00"
        '// verify Minutes.
        If lblMinutes.Text > "00" And lblSeconds.Text = "00" Then
            lblMinutes.Text -= 1
            lblSeconds.Text = "60"
        End If

        If lblSeconds.Text.Length < 2 Then lblSeconds.Text = "0" & lblSeconds.Text '// format from "0" to "00"
        '// verify Seconds.
        If lblSeconds.Text > "00" Then lblSeconds.Text -= 1

        '// disable Timer.
        If lblHours.Text = "00" And lblMinutes.Text = "05" AndAlso lblSeconds.Text = "00" Then
            MsgBox("You only have 5 Minutes Remaining in your Account", MsgBoxStyle.Information)
        End If
        If lblHours.Text = "00" And lblMinutes.Text = "00" AndAlso lblSeconds.Text = "00" Then

            lblend.Text = Format(Now, "hh:mm tt") 'get stop time'


            Try
                cnn3.Open()
                sql1 = "UPDATE Users SET ([Hours], [Minutes], [Seconds] = VALUES(' 00 ',' 00 ',' 00 ')  WHERE ID = '" & frmLogin.txtUsername.Text & "'"
                Command1 = New OleDbCommand(sql1, cnn3)
                i2 = Command1.ExecuteNonQuery
            Catch ex As Exception

                cnn3.Close()
            End Try
            Timer2.Enabled = False
            frmLogin.ds = New DataSet 'reset dataset
        End If
    End Sub
End Class
Member Avatar for gowans07

msgbox the value from " Format(Now, "hh:mm tt")". What does it give you?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.