Results 1 to 2 of 2

Thread: Check to see if last record matches current.

  1. #1

    Thread Starter
    Hyperactive Member Pozzi's Avatar
    Join Date
    Feb 2001
    Location
    The Stones!
    Posts
    507

    Question Check to see if last record matches current.

    Hi,

    I have the following code: -

    Code:
            'Set Global Current System.
            strCurrentSystem = strCurrSystem
            lblCurrentSys.Text = strCurrSystem
    
            'Check to see if System is the current one in the table.
            Dim objTable As DataTable = EELDataSet.Tables("SystemLog")
    
            Dim objRows() As DataRow = objTable.Select()
            'Dim objRows() As DataRow = objTable.Select("System = '" & strCurrentSystem & "'", "System DESC")
            MsgBox(objRows.Length)
    
            'Add Current System to Log, if already in Don't.
            Dim newRow As EELDataSet.SystemLogRow
            newRow = EELDataSet.SystemLog.NewSystemLogRow()
    
            newRow.System = strCurrSystem
            newRow.VisitDate = Now()
    
            EELDataSet.SystemLog.Rows.Add(newRow)
    
            Try
                Me.SystemLogTableAdapter.Update(EELDataSet)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    Which isn't fully completed with regards to the logical steps, however, I'd like to check in a Table if the last record added has the 'System' that matches my variable strCurrentSystem.

    The table contains the columns ID, System, Date.

    The code is triggered by a Timer every X seconds and at the moment adds the current 'System' each time. I'd like it to check in the table that is the last 'System' matches the last record added, not to add it.

    My question is how/where do I place the SQL to carry out the check?

    Thanks & Regards
    VB.Net (VS 2010)

  2. #2

    Thread Starter
    Hyperactive Member Pozzi's Avatar
    Join Date
    Feb 2001
    Location
    The Stones!
    Posts
    507

    Re: Check to see if last record matches current.

    Hi,

    Scrub the above......

    I've added the following to find the last entry (System) added: -

    Code:
    Dim strLastSystem As String = objTable.Rows(objTable.Rows.Count - 1).Item("System").ToString()
    Thanks All
    VB.Net (VS 2010)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width