if i insert the new studadmin and the admincard and it Successfully Register but when i look at the access it not go the correct row is go to the timein and timeout

i not sure which part wrong:

Private Sub btnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegister.Click
        If String.IsNullOrWhiteSpace(txtcard.Text) Or String.IsNullOrWhiteSpace(txtadmno.Text) Then
            MessageBox.Show("Please complete the on the box.", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End If

        Dim Conn As System.Data.OleDb.OleDbConnection
        Dim ConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"
        Conn = New System.Data.OleDb.OleDbConnection(ConnectionString)


        Try
            If Conn.State = ConnectionState.Open Then Conn.Close()
            Conn.Open()

            Dim CMD As New System.Data.OleDb.OleDbCommand
            CMD.CommandText = "Select FROM tbl_studentadm WHERE [Stud Admin] ='" & txtadmno.Text & "' AND [Admin Card] = '" & txtcard.Text & "'"
            Dim sql As String = "insert into tbl_studentadm ([Stud Admin], [Admin Card]) values('" & txtadmno.Text & "', '" & txtcard.Text & "')"
            Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, Conn)
            sqlCom.Connection = Conn

            Dim result As Integer = sqlCom.ExecuteNonQuery()

            sqlCom.Dispose()
            Conn.Close()

            If result > 0 Then
                MessageBox.Show("Successfully Register.")
            Else
                MessageBox.Show("Failure to Register.")

            End If
            txtadmno.Text = ""
            txtcard.Text = ""
            txtadmno.Focus()

            Lecturer_Form.Show()
        Catch ex As Exception
            MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

    End Sub


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        lbltime.Text = "Time:" + TimeString

        If String.IsNullOrWhiteSpace(txtadmno.Text) Or String.IsNullOrWhiteSpace(txtcard.Text) Then
            'MessageBox.Show("Please complete the on the box.", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End If

        Using conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb")


            lbltime.Text = TimeOfDay.Hour & ":" & TimeOfDay.Minute & ":" & TimeOfDay.Second
            If TimeOfDay.Second < 10 Then
                Dim fitsecond As String
                fitsecond = TimeOfDay.Second
                lbltime.Text = TimeOfDay.Hour & ":" & TimeOfDay.Minute & ":" & "0" & fitsecond
            End If
            If TimeOfDay.Minute < 10 Then
                Dim fitminute As String
                fitminute = TimeOfDay.Minute
                lbltime.Text = TimeOfDay.Hour & ":" & "0" & fitminute & ":" & TimeOfDay.Second
            End If
            If TimeOfDay.Hour < 10 Then
                Dim fithour As String
                fithour = TimeOfDay.Hour
                lbltime.Text = "0" & fithour & ":" & TimeOfDay.Minute & ":" & TimeOfDay.Second
            End If

            Dim sql As String = "INSERT INTO tbl_studentadm (TimeIn, TimeOut) VALUES ('" & txtadmno.Text & "', '" & txtcard.Text & "')"
            Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, conn)
            sqlCom.Connection = conn
            conn.Open()

            Dim CMD As New System.Data.OleDb.OleDbCommand
            CMD.CommandText = "UPDATE tbl_StudentAdm SET [Stud Admin] = @StudAdmin WHERE TimeIn = @TimeIn"

            CMD.Parameters.AddWithValue("@StudAdmin", "Values")
            CMD.Parameters.AddWithValue("@TimeIn", "TimeOutValues")


            Dim result As Integer = sqlCom.ExecuteNonQuery()

            sqlCom.Dispose()
            conn.Close()

            If result > 0 Then
                ' MessageBox.Show("Insert time in.")
            Else
                MessageBox.Show("Failure to time in.")

            End If
        End Using

        'Catch ex As Exception
        'MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        'End Try
    End Sub

Please move this to the Software Development forum.

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.